如何在Open Office Calc表格上显示HTML格式的表格边框?
我们是一个ASP.NET Web应用程序。我正在生成Calc而不将其保存在服务器中并将其发送到客户端(浏览器)。为此,我通过Response对象生成并发送HTML代码到浏览器。当Content-Type设置为“ application / vnd.sun.xml.calc ”时,浏览器将其视为附件,Open Office将呈现HTML代码。但我在Calc电子表格上显示表格边框时遇到问题。作为注释,如果附件类型是MS Excel,这可以正常工作。我注意到,Calc不支持所有HTML标记。在这方面,我想知道如何在Calc中显示表格边框我的Response对象的HTML内容。
以下是代码段
protected void Page_Load(object sender, EventArgs e)
{
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.Buffer = true;
HttpContext.Current.Response.AddHeader("content-disposition", "attachment;filename=Sample.sxc");
HttpContext.Current.Response.Charset = "";
HttpContext.Current.Response.ContentType = "application/vnd.sun.xml.calc";
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
StringBuilder style = new StringBuilder();
style.Append(@"<style> ");
style.Append(@" .text { mso-number-format:\@; } ");
style.Append(@" .num { mso-number-format:\#\,\#\#0\.00; } ");
style.Append(@" .intg { mso-number-format:\#\,\#\#0; } ");
style.Append(@" .date { mso-number-format: 'Short Date'; } ");
style.Append(@" .date { mso-number-format: 'dd\/mm\/yyyy'; } ");
style.Append(@"</style>");
HttpContext.Current.Response.Write(style.ToString());
string s = @" <TABLE BORDER=""1"">
<TR>
<TD> <P> <U> <B> For Testing </B> </U> <BR> Generated By Sameer Bondasgfgzff </BR> </P>
</TD>
</TR>
<TR>
<TD width=""100px""> Sameer </TD>
</TR>
<TR> <TD width=""100px""> Srinivas </TD>
</TR>
</TABLE>"
;
HttpContext.Current.Response.Output.Write(s);
HttpContext.Current.Response.Flush();
HttpContext.Current.Response.End();
}
因为,我无法弄清楚,我尝试明确创建一个带边框的Calc表。但是,在将其保存为.HTML时,我收到一条警告消息,说格式化会受到干扰。如果我压制它并将其保存为.HTML,当我打开保存的.HTML thro Calc时,桌子周围的边界会消失。
我想知道如何在Open Office thro HTML的Calc工作表中显示该表的边框。 提前致谢。