Trying to understand C# and XML Spreadsheets in ASP.net -
Trying to understand C# and XML Spreadsheets in ASP.net -
i'm building web application give users same info see on table on current page, in excel spreadsheet format. found previous code in project did same thing.
small question first: know how column ss:width works? it's not exact match. column ss:autofitwidth="0" ss:width="114"
returns column width of 21.00...
where i'm having of problem is, of info passed spreadsheet has leading , tailing whitespace; have no thought how remove it. i've tried .trim()
when create .tostring()
query , i've been looking other methods, haven't seemed find it. next snippet of worksheet code:
<worksheet ss:name="usermgmt1"> <table> @*name*@ <column ss:autofitwidth="0" ss:width="114" /> <row> <cell ss:styleid="s29"> <data ss:type="string">name</data> </cell> </row> @foreach (tbl_users query in viewbag.contents ) { <row> <cell ss:styleid="s31"> <ss:data ss:type="string" > @(query.name.tostring().trim()) </ss:data> </cell> </row> } </table> </worksheet>
forgot add together actionresult implements code:
public actionresult _excel(tblusers model) { list<tbl_users> inquirieslist = usermanagemodel.getresults(model); viewbag.contents = inquirieslist; homecoming view("_excel"); }
and call:
@using (html.beginform("_excel", "usermanage", formmethod.post)) { <input type="submit" value="view detailed list of users in excel" /> }
the result looks in excel, much whitespace surrounding each string item:
administrator
according xml excel spec on msdn http://msdn.microsoft.com/en-us/library/aa140066(v=office.10).aspx#odc_xmlss_ss:column ss:width column width in points (which may render differently based on screen resolution, etc).
the spaces around trimmed text may due indenting. seek collapsing xml element this:
<ss:data ss:type="string" >@(query.name.tostring().trim())</ss:data>
c# asp.net-mvc-3 xml-spreadsheet
Comments
Post a Comment