使用 ClosedXML將DataGridView 匯出至 Excel Imports ClosedXML.Excel Public Sub ExportToExcel() Using stream As FileStream = New FileStream("D:\01.Project\Template.xlsx", FileMode.Open, FileAccess.ReadWrite) Using memoryStream As New MemoryStream() ' 初始化ExcelPackage,並讀取模板' Using workbook As New XLWorkbook(stream) Dim ws As IXLWorksheet = workbook.Worksheet(1) ' 假設操作第一個工作表' ' 匯出 DataGridView 標題' For col As Integer = 0 To DataGridView1.Columns.Count - 1 ws.Cell(1, col + 1).Value = DataGridView1.Columns(col).HeaderText Next ' 匯出 DataGridView 內容' For row As Integer = 0 To DataGridView1.Rows.Count - 1 For col As Integer = 0 To DataGridView1.Columns.Count - 1 Dim cellValue = DataGridView1.Rows(row).Cells(col).Value ws.Cell(row + 2, c...
# "==" set text0 = "World" set text1 = "World" set text2 = "Hello World" set text3 = "Hello World !!" if( $text2 == $text3) then echo "$text2 == $text3" else echo "$text2 != $text3" endif if( $text0 == text1) then echo "$text0 == $text1" else echo "$text0 != $text1" endif ------------------------------------------- output: Hello World !! != Hello World !! World == World # "=~" set text1 = "World" set text2 = "Hello World" set text3 = "Hello World !!" if( $text3 =~ $text2) then echo "$text2 is $text3 Substring" else echo "$text2 not $text3 Substring" endif if( $text2 =~ text1) then echo "$text1 is $text2 Substring" else echo "$text1 not $text2 Substring" endif ------------------------------------------- output: Hello World is Hello World !! Substring World is Hello World Substring By Hao★
留言
張貼留言
歡迎留言