使用EPPlus的Excel工作表标题 [英] Headers for Excel worksheet using EPPlus

查看:459
本文介绍了使用EPPlus的Excel工作表标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用EPPLus从我的数据集创建和格式化Excel表单。我想使用EPPlus在excel表上设置头文件。我找不到办法。我想设置左标题,右标题和中心标题。
我已经使用VBA代码完成了这个任务,但是我不得不离开这个代码。
在VBA中我只会执行

I am using EPPLus to create and format an excel sheet from my data set. I want to set headers on the excel sheet using EPPlus. I could not find a way to do it. I want to set the left header, right header and center header. I have done this using VBA code, but I wan to move away from that. In VBA I would just do

With ActiveSheet.PageSetup
.LeftHeader = ""
.RightHeader =""
.CenterHeader= ""
End With

帮帮我!!
谢谢

Help!! Thanks

PS:我正在创建一个winforms应用程序。我不知道这是否会改变任何东西,只是想在这里提及。谢谢

PS: I am creating a winforms application. I was not sure if that would change anything but just wanted to mention it here. Thanks

推荐答案

我终于弄清楚了。

It can be done using 
workSheet.HeaderFooter.FirstHeader.LeftAlignedText = ""
workSheet.HeaderFooter.FirstHeader.RightAlignedText = ""
workSheet.HeaderFooter.FirstHeader.CenterAlignedText = ""

这为First页设置。
FirstHeader 属性更改为 EvenHeader OddHeader

This sets for the First page. Changing the FirstHeader Property to EvenHeader and OddHeader sets if for the following pages.

有几个属性 differentFirst differentOddEven 如果页面具有不同的标题,则设置它们。但是我无法让它工作通过将它们设置为false并设置其中一个标题。
要单独设置所有三个。

There are a couple of properties differentFirst and differentOddEven which set if the pages have different headers. But I was not able to get it to work By setting them to false and just setting one of the headers. Had to set all three separately.

希望它是有用的
谢谢

Hope it is useful Thanks

这篇关于使用EPPlus的Excel工作表标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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