Xlsx样式获取错误的填充模式 [英] Xlsx styles getting wrong fill pattern

查看:115
本文介绍了Xlsx样式获取错误的填充模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个xlsx文件,我想在其中将自己的样式应用于工作表中的单元格.我有一种情况,样式1和样式2都指定纯红色,但是当我在excel中打开它时,第一个是灰色斑点,但是第二个是我所期望的.我很困惑..这是附件文件中xml的一些内容.

I am writing an xlsx file where I want to apply my own styles to cells in a worksheet. I have a case where style 1 and style 2 both specify solid red, but when I open it in excel the first is gray stippled but the second is what I expect. I am stumped.. Here are some bits of xml from the attached file.

在工作表中,我有2个单元格:

In the worksheet, I have 2 cells:

  <x:c t="inlineStr" s="2">
    <x:is>
      <x:t>looks right</x:t>
    </x:is>
  </x:c>
  <x:c t="inlineStr" s="1">
    <x:is>
      <x:t>looks wrong</x:t>
    </x:is>
  </x:c>

在styles.xml文件中,我定义这些单元格样式如下:

In the styles.xml file, I define these cell styles as follows:

<x:cellXfs>
  <x:xf borderId="0" fillId="0" fontId="0" numFmtId="0"/>
  <x:xf fillId="1" applyFill="1"/>
  <x:xf fillId="2" applyFill="1"/>      
</x:cellXfs>

填充在哪里:

<x:fills>
  <x:fill>
    <x:patternFill patternType="none"/>
  </x:fill>
  <x:fill>
    <x:patternFill patternType="solid">
      <x:fgColor rgb="FFFF0000"/>
    </x:patternFill>
  </x:fill>
  <x:fill>
    <x:patternFill patternType="solid">
      <x:fgColor rgb="FFFF0000"/>
    </x:patternFill>
  </x:fill>
</x:fills>

填充1和2均为纯红色,因此单元格样式1和2应该相同,对吗?但事实并非如此.

Fills 1 and 2 are both solid red, so cell styles 1 and 2 should be identical, right? But they are not.

这是一个Excel错误吗?有没有预定义的填充样式编号1可以覆盖我的定义?

Is this an Excel bug? Is there a pre-defined fill style numbered 1 that overrides my definition?

嗯,我看不到如何将文件附加到问题上……

Hmm, I don't see how to attach a file to a question...

推荐答案

原来,我的第二个猜测是正确的.填充#1硬接线为gray125. Excel在读取xml时会忽略此填充的定义.如果在某处有记录,那会很好.

Turns out that my second guess was right. Fill #1 is hardwired to gray125. Excel ignores the definition of this fill while reading the xml. Would have been nice if this were documented somewhere.

这篇关于Xlsx样式获取错误的填充模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆