c# - Export Datatable to Excel File (.XLSX) -


i use code export datatable excel file (.xlsx)

dim attachment string = "attachment; filename=excel.xlsx"     response.clearcontent()     response.addheader("content-disposition", attachment)     response.contenttype = "application/vnd.ms-excel"     dim tab string = ""     each dc datacolumn in dt.columns         response.write(tab + dc.columnname)         tab = vbtab     next     response.write(vblf)      dim integer     each dr datarow in dt.rows         tab = ""         = 0 dt.columns.count - 1             response.write(tab & dr(i).tostring())             tab = vbtab         next         response.write(vblf)     next     response.end() 

when download file message :

"excel cannot open file 'excel.xlsx' because file format or file extension not valid "

i use excel 2010

any ideas why ?!

your creating tsv - tab separated value. instead .xlsx try using .tsv


Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

excel vba - VBA Proxy auto-configuration for http requests -

php - phpWord - Tables with borders in headers/footers -