OpenXML - CellFormats - 我真的需要为每一种排列配置一个吗?
我目前正在使用 SDK v2.0 来生成 Excel 工作簿,一切进展顺利,直到我开始应用单元格格式。
我已经创建了一些 CellFormat 并成功应用了它们,但我还需要配置一些排列:
- 4 种字体(正常、粗体、斜体和粗体+斜体)
- 5 种数字格式
- 3 种对齐方式(左、右和中)
- 2 border(无边框和顶部+底部)
这相当于 120 种样式 - 我真的需要为每一种配置 CellFormat 吗? Surley,这就是通往疯狂的道路;-)
如果事情必须如此,那么我对 CellFormats 集合的生成感到满意,但我担心在应用它们时引用格式 - 这对我来说听起来太不稳定了。
我已经在 OpenXMLDeveloper 中发布了此内容,但在所以我希望 SO 能来拯救我。
I'm currently working with v2.0 of the SDK to generate an Excel workbook and it was all going well until I came to apply the cell formatting.
I've created a few CellFormats and successfully applied them but there are a few more permutations that I need to configure:
- 4 fonts (normal, bold, italic and bold+italic)
- 5 number formats
- 3 alignments (left, right and centre)
- 2 border (none and top+bottom)
This equates to 120 styles - do I really need to configure a CellFormat for each one? Surley that's the road to madness ;-)
If that's the way it has to be then I'm happy with the generation of the CellFormats collection but I'm concerned about referencing the formats when applying them - it all sounds too flaky to me.
I've posted this in OpenXMLDeveloper but it's still pretty quiet in there so I'm hoping the SO can come to my rescue.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
那么这个问题的答案似乎是肯定的!
我确定了可能的排列,并创建了一个接受 FontId 和 BorderId 等参数的方法。
然后,我调用该方法大约 20 次来创建我需要的样式集合。
我仍然认为这有点笨拙;-)
Well the answer to this question appears to be Yes!
I identified the possible permutations and created a method that accepted parameters such as FontId and BorderId.
I then just called the method about 20 times to create a collection of Styles that I needed.
I still think this is a bit on the clunky side ;-)