Dim core As String
Dim number As String
Dim expect As Double
Dim have As Double
Dim persen As String
Dim Sum1 As Double = 0
Dim chkdate As String = ""
For i = 0 To GridView1.Rows.Count - 1
number = CStr(i + 1)
core = GridView1.Rows(i).Cells(2).Text
expect = CDbl(GridView1.Rows(i).Cells(3).Text)
have = CDbl(GridView1.Rows(i).Cells(4).Text)
persen = GridView1.Rows(i).Cells(5).Text
.Range("A" & j.ToString()).Value = number + "." + core
.Range("A" & j.ToString()).HorizontalAlignment = Excel.XlHAlign.xlHAlignLeft
.Range("G" & j.ToString()).Value = expect
.Range("G" & j.ToString()).HorizontalAlignment = Excel.XlHAlign.xlHAlignRight
.Range("H" & j.ToString()).Value = have
.Range("H" & j.ToString()).HorizontalAlignment = Excel.XlHAlign.xlHAlignRight
.Range("I" & j.ToString()).Value = persen
.Range("I" & j.ToString()).HorizontalAlignment = Excel.XlHAlign.xlHAlignRight
j += 1
Next
ทำคำนวณใน footer แต่เวลา export to excel footer ไม่ออกนะ ไม่ทราบว่าเป็นที่ตรงไหน