asp.net - How to set width and background color of the cell while exporting to excel with multiple sheets in using ExcelHelper class -
i create multiple sheets in excel file not format cells giving proper width columns
i need display generated excel like:-
column1 column2
dataaaaaaaaaaaaaaaaiaaaaaaa 4 data data ggghjkkllil
aaaaaddfdfffgggggggggggggg 5
column1 , column2 should centrally aligned while column column1 , column2 data should wrapper text blue color background
this requires columns give proper width , text should wrapper text.unfortunately unable give proper styles.and want apply background color cell.for background color using
sb.appendformat(@" <interior ss:color=""#2e2efe""/>{0}", environment.newline);
but nt working. here giving code.
stringbuilder sb = new stringbuilder(818); 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=""11"" 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(@" <alignment ss:vertical=""bottom""/>{0}", environment.newline); sb.appendformat(@" <font ss:fontname=""calibri"" x:family=""swiss"" ss:size=""14"" 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=""s65"">{0}", environment.newline); sb.appendformat(@" <ss:borders>{0}", environment.newline); sb.appendformat(@" <ss:border ss:position=""bottom"" ss:linestyle=""continuous"" ss:weight=""1"" />{0}",environment.newline); sb.appendformat(@" <ss:border ss:position=""top"" ss:linestyle=""continuous"" ss:weight=""1"" />{0}", environment.newline); sb.appendformat(@" <ss:border ss:position=""left"" ss:linestyle=""continuous"" ss:weight=""1"" />{0}",environment.newline); sb.appendformat(@" <ss:border ss:position=""right"" ss:linestyle=""continuous"" ss:weight=""1"" />{0}", environment.newline); sb.appendformat(@" </ss:borders>{0}", environment.newline); sb.appendformat(@" <font ss:fontname=""calibri"" x:family=""swiss"" ss:size=""12"" ss:color=""#2e2efe""{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>"); return sb.tostring();
can me so..
i think late maybe got solution this. still giving solution working fine me.
for adding background use below code:-
sb.appendformat(@" <style ss:id=""backgroundyellow"">{0}", environment.newline); sb.appendformat(@" <interior ss:color= ""#008000"" ss:pattern=""solid"" />{0}", environment.newline); sb.appendformat(@" </style>{0}", environment.newline);
you have missed tag ss:pattern=""solid""
Comments
Post a Comment