带有 XML 的 Excel 电子表格

发布于 2024-08-24 00:53:29 字数 820 浏览 1 评论 0原文

我正在使用 XML 方法为报告创建 Excel 电子表格,您可以在其中导出有效的 Microsoft 格式的 XML,然后将其导出到 Excel。

到目前为止,一切正常,但我在颜色方面遇到了一些问题。

我创建了一种样式,例如:

<Style ss:ID="s64" ss:Parent="s25">
      <Font ss:FontName="Tahoma" x:Family="Swiss" ss:Size="14" ss:Color="#4579B9" ss:Bold="1"/>
      <Interior/>
</Style>

它应该使用的颜色应该看起来像但在该图像的顶部:

alt text http://img535.imageshack.us/img535/431/righty.jpg

但是,它使用的是底部的颜色。

当我生成报告时,它是用颜色代码生成的:#4579B9,这就是我想要的,但是当我打开它时,它显示的颜色是图像底部的颜色。

如果我随后保存文档,它会自动将颜色更改为#666699,这正是底部的颜色(错误的颜色)。

然而,这只发生在字体颜色上,就像我将任何单元格的背景颜色更改为#4579B9一样,它会正常工作。

我认为这与选择的颜色是“主题颜色”而不是“标准颜色”的一部分有关。

这里有人有生成此类报告并正确应用样式的经验吗?或者我错过了什么?

I'm creating excel spreadsheets for reports using the XML method, where you export a valid Microsoft formatted XML, and then export it to Excel.

So far everything works as it should, but I'm having some trouble with the colours.

I've created one style such as:

<Style ss:ID="s64" ss:Parent="s25">
      <Font ss:FontName="Tahoma" x:Family="Swiss" ss:Size="14" ss:Color="#4579B9" ss:Bold="1"/>
      <Interior/>
</Style>

The colours it's supposed to use, should look like the but on the top of this image:

alt text http://img535.imageshack.us/img535/431/righty.jpg

However, the colour it's using the the one on the bottom.

When I generate the report, it's generated with the colour code: #4579B9, which is what I want, but when I open it, it's displaying the colour as the one from the bottom of the image.

If I then save the document, it automatically changes the colour to be #666699, which is exactly what the colour on the bottom (wrong colour) is.

This however only happens with font colours, as if I change the background colour of any cell to be #4579B9, it will work normally.

I'm thinking it's got something to do with the colour selected being part of the "theme colours" as opposed to the "standard colours".

Does anyone here have any experience generating these kind of reports, and applying styles to it correctly? Or am I missing something?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

绅刃 2024-08-31 00:53:29

我相信您正在使用 Excel 2007,因为您使用的颜色和您提到的主题。以下颜色信息适用于 Excel 2003,这是我使用 SpreadsheetXML (XMLSS) 的唯一经验版本。

Excel 2003 仅支持有限数量的颜色。由于指定的颜色不是调色板的一部分,因此将使用最接近的匹配颜色。您需要做的是指定不同的调色板或将您的颜色与默认颜色之一相匹配。

以下是定义工作簿调色板的示例。我将索引#1 处的颜色(通常为白色)减少为较浅的白色(255、253、253)。

 <OfficeDocumentSettings xmlns="urn:schemas-microsoft-com:office:office">
  <RelyOnVML/>
  <AllowPNG/>
  <Colors>
   <Color>
    <Index>1</Index>
    <RGB>#FFFDFD</RGB>
   </Color>
  </Colors>
 </OfficeDocumentSettings>

I believe you are using Excel 2007 because of the colors you are using and you mentioned theme. The following color information is for Excel 2003, which is the only version I have experience with using SpreadsheetXML (XMLSS).

Excel 2003 only supports a limited number of colors. Since the specified color is not part of the color palette, the closest matching color is used. What you need to do is specify a different color palette or match your color to one of the default colors.

Following is an example of defining the color palette for a workbook. I reduce the color at Index #1, usually White, to a lighter shade of White (255, 253, 253).

 <OfficeDocumentSettings xmlns="urn:schemas-microsoft-com:office:office">
  <RelyOnVML/>
  <AllowPNG/>
  <Colors>
   <Color>
    <Index>1</Index>
    <RGB>#FFFDFD</RGB>
   </Color>
  </Colors>
 </OfficeDocumentSettings>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文