【问题标题】:export html to excel -- excel formatting not the same as specified in the html将 html 导出到 excel - excel 格式与 html 中指定的不同
【发布时间】:2013-08-29 23:04:18
【问题描述】:

我正在使用 Telerik asp.net 控件将网格的内容输出到 Excel。我自己创建 html,然后网格进行导出。我不确定网格是否在做任何花哨的事情,但这是我为导出创建的 html 的 sn-p .我在 vb.net stringbuilder 中创建导出

output.AppendLine("<!DOCTYPE html PUBLIC ""-//W3C//DTD XHTML 1.0 Transitional//EN"" ""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"">")
output.AppendLine("<html xmlns=""http://www.w3.org/1999/xhtml"">")
output.AppendLine("<head><style type=""text/css""> body {font: arial; font-size: 24px} .title {background-color: #eeeeee; font-size: 24px; font-weight:bold; height: 70px; vertical-align: middle;} .header{background-color: blue; font-weight=bold; text-align: left;} .data{border:1px solid black;text-align:left;vertical-align: top;} </style></head>")
output.AppendFormat("<body ><table><tr><td colspan=""8"" class=""title"" style=""width:1000px;"">{0} Report for {1} from {2: dd/MM/yyyy} to {3: dd/MM/yyyy}", Me.ReportTitle, GetCommaSeparatedListOfItems(cblVehicles, "vehicles"), dpStartDate.SelectedDate, dpEndDate.SelectedDate)

我遇到的问题是excel内容与我的html中指定的内容不一样。在 excel 中,标题是 calibri size 18 而不是 arial size 24。正文是 calibri 11 而不是 arial 24。

所以我有两个问题:

1) 在excel中打开文档时如何查看文档的html源代码 2)如何修复我的输出,以便 excel 文档显示 html 输出中的内容

非常感谢

【问题讨论】:

    标签: html excel


    【解决方案1】:

    以下示例可能会对您有所帮助:

    如何格式化-excel-file-with-styles-fonts-colors-tables-etc

    How to format excel file with styles, fonts, colors, tables etc with pure PHP?

    【讨论】:

    • 嗨 - 在发布问题之前我已经看到了。它没有帮助我解决我的问题以及为什么我的代码没有产生预期的格式
    猜你喜欢
    • 2014-10-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-05-15
    • 2018-06-24
    • 2023-03-21
    • 1970-01-01
    相关资源
    最近更新 更多