0

我们如何通过 HTML 在 Open Office Calc 表上显示表格边框?

我们的是一个 ASP.NET Web 应用程序。我正在即时生成 Calc 而不将其保存在服务器中并将其发送到客户端(浏览器)。为此,我通过 Response 对象生成 HTML 代码并将其发送到浏览器。由于 Content-Type 设置为“ application/vnd.sun.xml.calc ”,浏览器将其视为附件,Open Office 呈现 HTML 代码。但我无法在 Calc 电子表格上显示表格边框。请注意,如果附件类型是 MS Excel,这可以正常工作。我注意到,Calc 不支持所有 HTML 标签。在这方面,我想知道如何通过 Response 对象的 HTML 内容在 Calc 中显示表格边框。

下面是代码片段

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,并且当我通过 Calc 打开保存的 .HTML 时,表格周围的边框就会消失。

我想知道如何在 Open Office thro HTML 的 Calc 表中显示表格的边框。提前致谢。

4

0 回答 0