Click here to Skip to main content
16,021,687 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Please any suggest to export the data through c# to excel and need to save that file Excel binary format(as .xlsb).
Posted
Comments
CHill60 21-Jan-15 8:28am    
What have you tried? Can you export to Excel xls format?
Velu04 21-Jan-15 23:19pm    
Hi, i need to export details to Excel xlsb format. We have already doing export in Excel xls format. Due to large file size we planned to export to excel xlsb format.
CHill60 22-Jan-15 5:24am    
If you use Workbook.SaveAs when exporting to xls try using XlFileFormat.xlExcel12 as the format (2nd parameter to the SaveAs)
[no name] 21-Jan-15 9:45am    
If you want to export a excel from a grid view then the below code snippet can help you.I am not really sure on .xlsb format,but this works well with.xls.




HttpContext.Current.Response.Clear();
HttpContext.Current.Response.AddHeader("content-disposition", string.Format("attachment; filename={0}", fileName + ".xls"));
HttpContext.Current.Response.Charset = "";
HttpContext.Current.Response.ContentType = "application/ms-excel";
StringWriter stringWrite = new StringWriter();
HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
gv.RenderControl(htmlWrite);//gv is the gridview
HttpContext.Current.Response.Write(stringWrite.ToString());
HttpContext.Current.Response.End();
Velu04 21-Jan-15 23:24pm    
Hi mishra,

I checked in this way also. The file with xlsb saved but not able to open the following file. It shoes the error as " Excel cannot open the file "Testxlsb" because the file format or file extension is not valid".

Please support if any this wrong with me.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900