質問編集履歴
1
情報追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
VB.NETであるプログラムを作成しています。
|
2
2
|
DBと接続してデータグリッドビューにテーブルの情報を表示しています。
|
3
3
|
そこで、出力ボタンを押下した際にデータグリッドビューに表示しているデータをExcelに入力できるようにしたいです。
|
4
|
-
|
4
|
+
|
5
5
|
```
|
6
6
|
'出力ボタン
|
7
7
|
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
|
@@ -47,4 +47,16 @@
|
|
47
47
|
End Sub
|
48
48
|
```
|
49
49
|
一応今はこれでExcelにベタ書きで文字を入力することはできています。
|
50
|
+
|
51
|
+
```
|
52
|
+
For i As Integer = 0 To DataGridView1.Rows.Count - 1
|
53
|
+
|
54
|
+
sheet.Range(1, i).Value = DataGridView1.Rows(i).Cells(1).Value
|
55
|
+
sheet.Range(2, i).Value = DataGridView1.Rows(i).Cells(4).Value
|
56
|
+
sheet.Range(3, i).Value = DataGridView1.Rows(i).Cells(5).Value
|
57
|
+
sheet.Range(4, i).Value = DataGridView1.Rows(i).Cells(6).Value
|
58
|
+
sheet.Range(5, i).Value = DataGridView1.Rows(i).Cells(7).Value
|
50
|
-
|
59
|
+
Next
|
60
|
+
```
|
61
|
+
Excelの方に一行文だけ入力できました。
|
62
|
+
後はExcelの方でA2,A3,A4,A5...と各セルを下にずらしていきたいのですがそのやり方がわかりません。
|