0

我正在使用 Telerik asp.net 控件将网格的内容输出到 Excel。我自己创建 html,然后网格进行导出。我不确定网格是否在做任何花哨的事情,但这是我为 export 创建的 html 片段。我在 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 大小 18 而不是 arial 大小 24。正文是 calibri 11 而不是 arial 24。

所以我有两个问题:

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

多谢

4

1 回答 1

0

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

How-to-format-excel-file-with-styles-fonts-colors-tables-etc

如何使用纯 PHP 格式化带有样式、字体、颜色、表格等的 excel 文件?

于 2013-08-29T15:04:18.327 回答