Click here to Skip to main content
15,898,035 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
hello all,
I am using VS 2008, sql2k8 want to export a data grid to excel please help.

thanks in advance
Sanjeev Singh
Posted

1 solution

Hi Sanjeev,
You can refer to this site.
http://www.lateral8.com/articles/2010/3/5/openxml-sdk-20-export-a-datatable-to-excel.aspx

If you want to apply formatting to the excelsheet then ypu can refer to:
http://www.lateral8.com/articles/2010/6/11/openxml-sdk-20-formatting-excel-values.aspx

If you want to Apply protection to the sheet cells:
SheetProtection sheetProtection1 = new SheetProtection() { Sheet = true, Objects = true, Scenarios = true };
 worksheet3.Append(sheetProtection1);


If you want to unlock a specific cell:
In CellFormat method:
if (blnIsLockedOrNot == true)
           {
               Protection protection = new Protection { Locked = false };
               cellFormat.Append(protection);
           }
 
Share this answer
 
v2

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