teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

3

2020/10/09 15:55

投稿

Yamamin
Yamamin

スコア18

title CHANGED
File without changes
body CHANGED
@@ -15,12 +15,13 @@
15
15
  ICell cell = null;
16
16
 
17
17
  row = ws.GetRow(0);
18
- cell = row.GetCell(0) ?? row.CreateCell(0); cell.SetCellValue(20000);
18
+ cell = row.GetCell(0) ?? row.CreateCell(0);
19
+ cell.SetCellValue(20000);
19
20
 
20
21
  using (System.IO.FileStream f = new System.IO.FileStream(ExcelFilePath, System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.Write))
21
22
  {
22
- wb.Write(f);
23
+ wb.Write(f);
23
- f.Close();
24
+ f.Close();
24
25
  }
25
26
 
26
27
  コード

2

2020/10/09 15:55

投稿

Yamamin
Yamamin

スコア18

title CHANGED
File without changes
body CHANGED
@@ -8,21 +8,20 @@
8
8
 
9
9
  2.プログラム上から以下のようにして、「Sheet2」の「A1」セルに値を設定します。
10
10
 
11
-  ```   IWorkbook wb = WorkbookFactory.Create(ExcelFilePath);
11
+  ``` IWorkbook wb = WorkbookFactory.Create(ExcelFilePath);
12
- ISheet ws = wb.GetSheet("Sheet2");
12
+ ISheet ws = wb.GetSheet("Sheet2");
13
13
 
14
- IRow row = null;
14
+ IRow row = null;
15
- ICell cell = null;
15
+ ICell cell = null;
16
16
 
17
- row = ws.GetRow(0);
17
+ row = ws.GetRow(0);
18
- cell = row.GetCell(0) ?? row.CreateCell(0);
18
+ cell = row.GetCell(0) ?? row.CreateCell(0); cell.SetCellValue(20000);
19
- cell.SetCellValue(20000);
20
19
 
21
- using (System.IO.FileStream f = new System.IO.FileStream(ExcelFilePath, System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.Write))
20
+ using (System.IO.FileStream f = new System.IO.FileStream(ExcelFilePath, System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.Write))
22
- {
21
+ {
23
- wb.Write(f);
22
+ wb.Write(f);
24
- f.Close();
23
+ f.Close();
25
- }
24
+ }
26
25
 
27
26
  コード
28
27
  ```

1

2020/10/09 15:53

投稿

Yamamin
Yamamin

スコア18

title CHANGED
File without changes
body CHANGED
@@ -8,7 +8,7 @@
8
8
 
9
9
  2.プログラム上から以下のようにして、「Sheet2」の「A1」セルに値を設定します。
10
10
 
11
-     IWorkbook wb = WorkbookFactory.Create(ExcelFilePath);
11
+  ```   IWorkbook wb = WorkbookFactory.Create(ExcelFilePath);
12
12
  ISheet ws = wb.GetSheet("Sheet2");
13
13
 
14
14
  IRow row = null;
@@ -24,6 +24,8 @@
24
24
  f.Close();
25
25
  }
26
26
 
27
+ コード
28
+ ```
27
29
  3. エクセルファイルを開いて、「Sheet2」の「A1」セルには「20000」と設定
28
30
    されていますが、「Sheet1」の「A1」セルを見ても0のままです。
29
31
    手動で、「Sheet2」の「A1」セルに「20000」と設定しなおすと、