I want to export gridview to excel file and import excel to gridvie.
when i open this exported file I am getting the following warning message.
The file format and extension of 'Export.xls' don't match the file could not be correpted or unsafe. Unless you trust its source, don't open it. Do you want to open it anyway ?
I searched for this warning message but i am not getting correct result.
In Excel file old version(2003) format it is working properly but when I open this file in latest version (after 2007) I am getting warning message and my operations also failed.
so pleas tell me how to export and import gridview in latest version excel file .
Vithal WadjePosted Oct 23, 2012, 6:11 AM
raja rameshPosted Oct 22, 2012, 5:45 AM
Thank you for reply, I unable to get data from bytes. In you case you have written one of the line
com.Parameters.Add("@Data", SqlDbType.Binary).Value = bytes;
But how can i use this li, In my case I have Customer table and it has customerid(pk), customerName, address,... so how can i achieve data from bytes.
Thanks in advance,
raja
Lacy MichellePosted Oct 22, 2012, 2:58 AM
export gridview to excel, look at below code:
private void btnRun_Click(object sender, System.EventArgs e)
{
Workbook workbook = new Workbook();
//Initialize worksheet
Worksheet sheet = workbook.Worksheets[0]; sheet.InsertDataTable((DataTable)this.dataGrid1.DataSource,true,2,1,-1,-1);
workbook.SaveToFile("sample.xls");
ExcelDocViewer( workbook.FileName );
}
excel to datatable:
Vithal WadjePosted Oct 20, 2012, 8:48 AM