質問編集履歴

1

環境と参考サイト、コードについて記載を追加しました。

2018/10/09 05:37

投稿

tsutsumi800
tsutsumi800

スコア13

test CHANGED
File without changes
test CHANGED
@@ -14,4 +14,58 @@
14
14
 
15
15
 
16
16
 
17
+ 環境:visual studio2017 , windows formアプリケーション(C#)
18
+
19
+
20
+
21
+ 参考サイト:http://excelcsharp.lance40.com/post-3.html
22
+
23
+
24
+
25
+
26
+
27
+ private void button1_Click(object sender, EventArgs e)
28
+
29
+ {
30
+
31
+ // Excel操作用オブジェクト
32
+
33
+ Microsoft.Office.Interop.Excel.Application xlApp = null;
34
+
35
+ Microsoft.Office.Interop.Excel.Workbooks xlBooks = null;
36
+
37
+ Microsoft.Office.Interop.Excel.Workbook xlBook = null;
38
+
39
+ Microsoft.Office.Interop.Excel.Sheets xlSheets = null;
40
+
41
+ Microsoft.Office.Interop.Excel.Worksheet xlSheet = null;
42
+
43
+
44
+
45
+ //ここにコードを追加して現在開いているシートを指定し、↓につなげたいです
46
+
47
+
48
+
49
+
50
+
51
+ // B3セルを指定
52
+
53
+ xlCells = xlSheet.Cells;
54
+
55
+ xlRange = xlCells[3, 2] as Microsoft.Office.Interop.Excel.Range;
56
+
57
+
58
+
59
+ // 現在の値を表示
60
+
61
+ MessageBox.Show(xlRange.Value);
62
+
63
+
64
+
17
- よろしくお願いします。
65
+ // 値を設定
66
+
67
+ xlRange.Value = "変更後の値";
68
+
69
+
70
+
71
+ }