質問編集履歴
3
この件とは関係のない処理を削除しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -24,23 +24,19 @@
|
|
24
24
|
|
25
25
|
```
|
26
26
|
|
27
|
-
private static bool CheckTransExport( Excel.Application xlApp, Excel.Workbook xlBook, DataTable transData, ref bool warnFlg, ref List<string> warnList, ref int regCount ) {
|
27
|
+
private static bool CheckTransExportDebug( Excel.Application xlApp, Excel.Workbook xlBook, DataTable transData, ref bool warnFlg, ref List<string> warnList, ref int regCount ) {
|
28
28
|
|
29
29
|
|
30
30
|
|
31
31
|
Excel.Worksheet xlSheet = null;
|
32
32
|
|
33
|
-
Excel.Range
|
33
|
+
Excel.Range targetCells = null;
|
34
|
+
|
35
|
+
Excel.Range targetRange = null;
|
36
|
+
|
37
|
+
|
34
38
|
|
35
39
|
try {
|
36
|
-
|
37
|
-
// Excelアプリケーション設定
|
38
|
-
|
39
|
-
xlApp.ScreenUpdating = false; //画面再描画を停止
|
40
|
-
|
41
|
-
xlApp.Calculation = Excel.XlCalculation.xlCalculationManual; //数式再計算を停止
|
42
|
-
|
43
|
-
xlApp.Visible = false; //Excelを非表示
|
44
40
|
|
45
41
|
|
46
42
|
|
@@ -50,157 +46,13 @@
|
|
50
46
|
|
51
47
|
|
52
48
|
|
53
|
-
//
|
49
|
+
// セルへ書き込み
|
54
50
|
|
55
|
-
|
51
|
+
targetCells = xlSheet.Cells;
|
56
52
|
|
57
|
-
|
53
|
+
targetRange = (Excel.Range)targetCells[15, 12];
|
58
54
|
|
59
|
-
|
60
|
-
|
61
|
-
// Excelシートの型式コード、ディストリコード列をDataTableへセット
|
62
|
-
|
63
|
-
DataTable tblSheet = ExcelUtilsForTrans.GetValueTable( xlSheet,
|
64
|
-
|
65
|
-
DOWNLOAD_BOOK,
|
66
|
-
|
67
|
-
SHEET_EXPORT,
|
68
|
-
|
69
|
-
(int)DataStartRow.ExportSheet,
|
70
|
-
|
71
|
-
(int)ColIndexForExport.ColProductSumFlgHid, maxRow,
|
72
|
-
|
73
|
-
(int)ColIndexForExport.ColProductDistributerCdHid );
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
string productModelCd = string.Empty;
|
84
|
-
|
85
|
-
string productModelNm = string.Empty;
|
86
|
-
|
87
|
-
string countryCd = string.Empty;
|
88
|
-
|
89
|
-
string distributerCd = string.Empty;
|
90
|
-
|
91
|
-
string productSumRowFlg = string.Empty;
|
92
|
-
|
93
|
-
string distributerSumRowFlg = string.Empty;
|
94
|
-
|
95
|
-
int colIdx = 0; // 列番号
|
96
|
-
|
97
|
-
int rowIdx = 0; // 行番号
|
98
|
-
|
99
|
-
int arraycolIdx = 0; // 転記先配列_列番号
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
// データクリア
|
104
|
-
|
105
|
-
foreach ( DataRow Row in tblSheet.Rows ) {
|
106
|
-
|
107
|
-
rowIdx++;
|
108
|
-
|
109
|
-
productModelCd = StringUtils.ToString( Row[CLM_NAME_EXPORT_PRODUCT_MODEL_CD] );
|
110
|
-
|
111
|
-
distributerCd = StringUtils.ToString( Row[CLM_NAME_EXPORT_DISTRIBUTER_CD] );
|
112
|
-
|
113
|
-
productSumRowFlg = StringUtils.ToString( Row[CLM_NAME_EXPORT_PRODUCT_SUM_FLG] );
|
114
|
-
|
115
|
-
distributerSumRowFlg = StringUtils.ToString( Row[CLM_NAME_EXPORT_DISTRIBUTER_SUM_FLG] );
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
if ( "1" != productSumRowFlg && "1" != distributerSumRowFlg ) {
|
120
|
-
|
121
|
-
// 合計行以外
|
122
|
-
|
123
|
-
for ( colIdx = 0; colIdx <= ITEM_COUNT_EXPORT - 1; colIdx++ ) {
|
124
|
-
|
125
|
-
arraycolIdx = NumericUtils.ToInt( transInfoArrayForExport[colIdx][(int)TransInfoIndex.ColIdx] );
|
126
|
-
|
127
|
-
xlSheet.Cells[rowIdx + DataStartRow.ExportSheet, arraycolIdx] = "";
|
128
|
-
|
129
|
-
}
|
130
|
-
|
131
|
-
}
|
132
|
-
|
133
|
-
}
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
// データチェック
|
138
|
-
|
139
|
-
// 対象データのループ処理
|
140
|
-
|
141
|
-
foreach ( DataRow Row in transData.Rows ) {
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
if ( StringUtils.ToString( Row[Constants.CLM_NAME_PRODUCT_YM] ) == StringUtils.ToString( Row[Constants.CLM_NAME_PLAN_YM] ) ) {
|
146
|
-
|
147
|
-
colIdx = 0;
|
148
|
-
|
149
|
-
rowIdx = 0;
|
150
|
-
|
151
|
-
productModelCd = StringUtils.ToString( Row[Constants.CLM_NAME_PRODUCT_MODEL_CD] );
|
152
|
-
|
153
|
-
countryCd = StringUtils.ToString( Row[Constants.CLM_NAME_COUNTRY_CD] );
|
154
|
-
|
155
|
-
distributerCd = StringUtils.ToString( Row[Constants.CLM_NAME_DISTRIBUTER_CD] );
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
// ディストリコードの3桁と国コードが一致する行を検索
|
160
|
-
|
161
|
-
rowIdx = GetExcelRowIdxModelCdCountryCd( tblSheet, (int)DataStartRow.ExportSheet, productModelCd, countryCd, CLM_NAME_EXPORT_PRODUCT_MODEL_CD, CLM_NAME_EXPORT_DISTRIBUTER_CD );
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
if ( -1 == rowIdx ) {
|
166
|
-
|
167
|
-
// 該当行なし
|
168
|
-
|
169
|
-
// 警告リスト追加
|
170
|
-
|
171
|
-
// 警告メッセージ 65040:Excelに存在しません。(値 型式コード:{0}、型式名:{1}、ディストリコード:{2})
|
172
|
-
|
173
|
-
MsgDef msgDef = MsgManager.MESSAGE_WRN_65040;
|
174
|
-
|
175
|
-
productModelNm = StringUtils.ToString( Row[Constants.CLM_NAME_PRODUCT_MODEL_NM] );
|
176
|
-
|
177
|
-
ExcelUtils.SetErrorListForExcelTrans( ref warnList, ref warnFlg, ref warnFlg, new Msg( msgDef, productModelCd, productModelNm, distributerCd ) );
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
continue;
|
182
|
-
|
183
|
-
}
|
184
|
-
|
185
|
-
}
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
if ( 0 < rowIdx ) {
|
190
|
-
|
191
|
-
// 該当行が存在する場合、貼付け
|
192
|
-
|
193
|
-
xlSheet.Cells[rowIdx, NumericUtils.ToInt( transInfoArrayForExport[colIdx][(int)TransInfoIndex.ColIdx] )] = Row[Constants.CLM_NAME_QUANTITY];
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
regCount++;
|
198
|
-
|
199
|
-
}
|
200
|
-
|
201
|
-
colIdx++;
|
202
|
-
|
203
|
-
}
|
55
|
+
targetRange.Value2 = "10";
|
204
56
|
|
205
57
|
|
206
58
|
|
@@ -214,27 +66,23 @@
|
|
214
66
|
|
215
67
|
} finally {
|
216
68
|
|
217
|
-
xlApp.ScreenUpdating = true; // 画面再描画を再開
|
218
|
-
|
219
|
-
xlApp.Calculation = Excel.XlCalculation.xlCalculationAutomatic; // 数式再計算を再開
|
220
|
-
|
221
|
-
xlApp.Visible = true; // Excelを表示
|
222
|
-
|
223
69
|
|
224
70
|
|
225
71
|
// Excelリソース解放
|
226
72
|
|
227
|
-
|
73
|
+
Marshal.ReleaseComObject( targetRange );
|
228
74
|
|
229
|
-
|
75
|
+
Marshal.ReleaseComObject( targetCells );
|
230
76
|
|
231
|
-
ExcelUtilsForTrans.ReleaseExcelComObject( lastcell );
|
232
77
|
|
233
|
-
ExcelUtilsForTrans.ReleaseExcelComObject( xlSheet );
|
234
78
|
|
235
|
-
|
79
|
+
Marshal.ReleaseComObject( xlSheet );
|
236
80
|
|
81
|
+
Marshal.ReleaseComObject( xlBook );
|
82
|
+
|
237
|
-
|
83
|
+
Marshal.ReleaseComObject( xlApp );
|
84
|
+
|
85
|
+
|
238
86
|
|
239
87
|
}
|
240
88
|
|
2
ソースコードのブロック化
test
CHANGED
File without changes
|
test
CHANGED
@@ -22,7 +22,9 @@
|
|
22
22
|
|
23
23
|
###該当のソースコード
|
24
24
|
|
25
|
+
```
|
26
|
+
|
25
|
-
|
27
|
+
private static bool CheckTransExport( Excel.Application xlApp, Excel.Workbook xlBook, DataTable transData, ref bool warnFlg, ref List<string> warnList, ref int regCount ) {
|
26
28
|
|
27
29
|
|
28
30
|
|
@@ -236,7 +238,9 @@
|
|
236
238
|
|
237
239
|
}
|
238
240
|
|
239
|
-
}
|
241
|
+
}
|
242
|
+
|
243
|
+
```
|
240
244
|
|
241
245
|
|
242
246
|
|
1
プログラムコードをブロックに修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -22,7 +22,7 @@
|
|
22
22
|
|
23
23
|
###該当のソースコード
|
24
24
|
|
25
|
-
private static bool CheckTransExport( Excel.Application xlApp, Excel.Workbook xlBook, DataTable transData, ref bool warnFlg, ref List<string> warnList, ref int regCount ) {
|
25
|
+
`private static bool CheckTransExport( Excel.Application xlApp, Excel.Workbook xlBook, DataTable transData, ref bool warnFlg, ref List<string> warnList, ref int regCount ) {
|
26
26
|
|
27
27
|
|
28
28
|
|
@@ -236,7 +236,7 @@
|
|
236
236
|
|
237
237
|
}
|
238
238
|
|
239
|
-
}
|
239
|
+
}`
|
240
240
|
|
241
241
|
|
242
242
|
|