VB.Net How to export every 'n' number of rows from DataGridView to different tabs in Excel -
i have dgv 500 rows , 15 columns. have 5 team members. have allot equal amount of rows members. so, in above e.g. have send 100 rows each of team member dgv. first 100 rows go emp#1, rows 101 - 200 go emp#2, , on..
i checked this , this not able try code logic working.
i looking in vb.net only.
thx in advance.
edit: we're little tight on budget, not able invest in plugin now.
you can use easyxls excel library export excel file 5 sheets , 100 rows each:
' create instance of class exports excel files, having 5 sheets dim xls new exceldocument(5) dim n integer = datagridview.rows.count()/5 sheet integer = 0 4 ' set sheet names xls.easy_getsheetat(sheet).setsheetname("emp#" & (sheet+1)) ' sheet table stores data dim xlstab excelworksheet = xls.easy_getsheetat(sheet) dim xlstable = xlstab.easy_getexceltable() dim tablerow = 0 ' add data in cells row integer = 0 n - 1 column integer = 0 datagridview.columns.count() - 1 xlstable.easy_getcell(tablerow, column).setvalue( _ datagridview.rows(n*sheet + row).cells(column).value.tostring()) next tablerow = tablerow + 1 next next ' export excel file xls.easy_writexlsxfile("c:\samples\excel.xlsx")
for more details formatting , how use library, can start link explains how export datagridview excel.
Comments
Post a Comment