Click here to Skip to main content
16,015,351 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Friends,

I need the excel export from dataset. in the dataset multiple tables will be there regarding that excel sheet.i done the code for that but i need to format in standard template like sheet page landscape setting and printpreview are need to fix. please find the below code which i'm using for that, and do revert back with some code and url's which related with this...

sb.AppendFormat(@"<?xml version=""1.0""?>{0}", Environment.NewLine);
       sb.AppendFormat(@"<?mso-application progid=""Excel.Sheet""?>{0}", Environment.NewLine);
       sb.AppendFormat(@"<Workbook xmlns=""urn:schemas-microsoft-com:office:spreadsheet""{0}", Environment.NewLine);
       sb.AppendFormat(@" xmlns:o=""urn:schemas-microsoft-com:office:office""{0}", Environment.NewLine);
       sb.AppendFormat(@" xmlns:x=""urn:schemas-microsoft-com:office:excel""{0}", Environment.NewLine);
       sb.AppendFormat(@" xmlns:ss=""urn:schemas-microsoft-com:office:spreadsheet""{0}", Environment.NewLine);
       sb.AppendFormat(@" xmlns:html=""http://www.w3.org/TR/REC-html40"">{0}", Environment.NewLine);
       sb.AppendFormat(@" <Styles>{0}", Environment.NewLine);
       sb.AppendFormat(@"  <Style ss:ID=""Default"" ss:Name=""Normal"">{0}", Environment.NewLine);
       sb.AppendFormat(@"   <Alignment ss:Vertical=""Bottom""/>{0}", Environment.NewLine);

       sb.AppendFormat(@"   <Borders />{0}", Environment.NewLine);
       sb.AppendFormat(@"   <Font ss:FontName=""Calibri"" x:Family=""Swiss"" ss:Size=""10"" ss:Color=""#000000""/>{0}", Environment.NewLine);
       sb.AppendFormat(@"   <Interior/>{0}", Environment.NewLine);
       sb.AppendFormat(@"   <NumberFormat/>{0}", Environment.NewLine);
       sb.AppendFormat(@"   <Protection/>{0}", Environment.NewLine);
       sb.AppendFormat(@"  </Style>{0}", Environment.NewLine);


       sb.AppendFormat(@"  <Style ss:ID=""s62"">{0}", Environment.NewLine);

       sb.AppendFormat(@"   <Font ss:FontName=""Calibri"" x:Family=""Swiss"" ss:Size=""12"" ss:Color=""#000000""{0}", Environment.NewLine);
       sb.AppendFormat(@"    ss:Bold=""1""/>{0}", Environment.NewLine);
       sb.AppendFormat(@"  </Style>{0}", Environment.NewLine);

       sb.AppendFormat(@"  <Style ss:ID=""s63"">{0}", Environment.NewLine);
       sb.AppendFormat(@"   <NumberFormat ss:Format=""Short Date""/>{0}", Environment.NewLine);
       sb.AppendFormat(@"  </Style>{0}", Environment.NewLine);
       sb.AppendFormat(@" </Styles>{0}", Environment.NewLine);
       sb.Append(@"{0}\r\n</Workbook>");
Posted
Updated 9-Jan-13 22:24pm
v4

Hi,

Check the following links for formating the excel sheet.

1 Link-1
2. Link-2
3. Link-3
4. Link-4(IMP)


Thanks
 
Share this answer
 

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