C# Excel 页脚问题

发布于 2024-07-09 17:30:37 字数 258 浏览 11 评论 0原文

我正在创建一个 C# Windows 应用程序来创建 Excel 2003 工作表。 需要添加到页脚:第 1 页(共 4 页)。

我目前拥有它,因此它将“页:&[Page] of &[Pages]”放入 Excel 工作表的页脚中。

当我打开创建的文档并查看页脚时,我会看到“页:页]页]”

我可以单击文本,它会突出显示它并显示它应该显示的内容,并且之后可以正常工作。

有什么方法可以让它从一开始就正常工作吗?

I am creating a C# windows application to create an Excel 2003 sheet. There is a requirement to add to the footer: Page 1 of 4.

I currently have it so it puts "Page: &[Page] of &[Pages]" into the footer of the excel sheet.

When I open up the created document and look at the footer I see "Page: Page] of Pages]"

I can click on the text, it highlights it and shows what it should, and works correctly after that.

Is there any way to get it to work correctly from the start?

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

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

发布评论

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

评论(1

一人独醉 2024-07-16 17:30:37

在 Excel 2007 中,如果您键入以下内容作为页脚:

Page &[Page] of &[Pages]

然后进入 VBA 编辑器立即窗口并输入以下内容:

print ActiveSheet.PageSetup.CenterFooter

结果是:

Page &P of &N

换句话说,代码中设置的值与用户界面中键入的值不同。

鉴于 Microsoft 将向后兼容性视为某种圣旨,我强烈怀疑您在 Excel 2003 中看到了同样的情况 - 尝试修改代码以设置“Page &P of &N”。

In Excel 2007 if you type this as your footer:

Page &[Page] of &[Pages]

Then go into the VBA editor Immediate window and enter this:

print ActiveSheet.PageSetup.CenterFooter

the result is:

Page &P of &N

In other words, the value set in the code is different from the one typed in the user interface.

Given that Microsoft treats backward compatibility like some kind of holy writ, I strongly suspect you're seeing the same thing in Excel 2003 - try modifying your code to set "Page &P of &N" instead.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文