我有工作表,它有數據由WinForms Application.Please輸出導出,以便更好地瞭解數據如何存在在工作表Here中。現在我想要的是合併具有Ex的公共值的單元格。我的一列中有InvoiceID,因此InvoicID內會有一些項目。我想合併那些等於項目的行,但它只能爲這些記錄顯示一次。爲了更好的理解檢查這個我手動執行的屏幕截圖Here。 有什麼辦法可以使用代碼執行相同的操作。 以下是我用來將數據導出到Excel的代碼。需要合併Excel文件的列數據,同時從vb.net導出應用程序
`昏暗excelConverter作爲新GridGroupingExcelConverterControl
昏暗exportingOptions作爲新ExcelExportingOptions excelConverter.ExportToExcel(GridGroupingControl1 「Sample.xlsx」,exportingOptions)
的Process.Start( 「Sample.xlsx」)
Dim xlApp As Excel.Application
Dim xlWorkBook As Excel.Workbook
Dim xlWorkSheet As Excel.Worksheet
Dim misValue As Object = System.Reflection.Missing.Value
Dim i As Integer
Dim j As Integer
xlApp = New Excel.Application
xlWorkBook = xlApp.Workbooks.Add(misValue)
xlWorkSheet = xlWorkBook.Sheets("sheet1")
For i = 0 To dgvSearch.RowCount - 2
For j = 0 To dgvSearch.ColumnCount - 1
xlWorkSheet.Cells(i + 1, j + 1) = _
dgvSearch(j, i).Value.ToString()
Next
Next
xlWorkBook.SaveAs("\vbexcel.xlsx")
xlWorkBook.Close()
xlApp.Quit()
releaseObject(xlApp)
releaseObject(xlWorkBook)
releaseObject(xlWorkSheet)
MsgBox("You can find the file C:\vbexcel.xlsx")`
我是新來的導出數據到Excel中,這將是非常有益的。 謝謝,
感謝豐富,會嘗試。 –