在EPPlus冻结列(一个Excel拆分功能) [英] Freezing columns in EPPlus (an Excel split function)

查看:3211
本文介绍了在EPPlus冻结列(一个Excel拆分功能)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经工作了很多EPPlus生成Excel文件,我的项目需要我做出口的数量。大多数,他们希望往往在出口,以便与他们已经在他们的遗留系统完美的出口匹配。其中之一,然而,他们希望的不同。他们希望它看起来就像从旧系统的后,他们已经做了一些典型的和具体的编辑的出口产品之一

I've been working a lot with EPPlus to generate Excel files for the number of exports that my project requires me to do. Most of the exports that they want tend to match up perfectly with exports that they have already in their legacy system. One of them, however, they want different. They want it to look exactly like one of the exports from the legacy system after they've done some typical and specific edits.

一些的编辑,他们这样做,虽然,使每一行长了很多比他们希望它是,所以他们要保留一些锁定到位屏幕上的列信息,而其他列则可以滚动正常(即Excel的拆分功能)。我试着 ws.Column锁定列(6).Style.Locked = TRUE ,但似乎并没有工作。我也试过一个单元格区域的锁定属性设置为true,但也没有奏效。

Some of the edits that they do, though, make each row a lot longer than they want it to be, so they want to keep some of the column information locked in place on the screen while the rest of the columns can be scrolled as normal (i.e. Excel's split function). I've tried locking the columns with ws.Column(6).Style.Locked = true, but that doesn't seem to work. I've also tried setting a cell range's Locked property to true but that also hasn't worked.

如何我可以冻结列的地方?

How can I freeze the columns in place?

推荐答案

原来,EPPlus有这样做的内置函数工作表本身调用的对象 FreezePanes 。这个函数有两个参数,这两者都是 INT :行和列。这样做会冻结您希望锁定到位,同时查看工作表中的任何行或列。

It turns out that EPPlus has a built-in function for doing that on the Worksheet object itself called FreezePanes. This function has 2 parameters, both of which are int: Row and Column. Doing this will freeze whatever rows or columns you wish to have locked in place while viewing the worksheet.

之一EPPlus网站上的例子使用它,虽然它不是示例的主要焦点/这个例子可以发现这里

One of the examples on the EPPlus website uses it, although it's not the main focus of the example/ That example can be found here.

有一个疑难杂症使用此功能,你应该知道,虽然:您使用的行或列参数的数量实际上是的第一列是不会冻结到位的。换句话说,如果你想第5列被冻结,你将不得不作出以下调用:

There is one gotcha with this function that you should know about, though: The number that you use for the row or column parameter is actually the first column that is NOT frozen in place. In other words, if you want the first 5 columns to be frozen you would have to make the following call:

ws.View.FreezePanes( 1,6)(其中6是第一列,它是不冻结)

ws.View.FreezePanes(1,6) (Where 6 is the first column that is not frozen)

这篇关于在EPPlus冻结列(一个Excel拆分功能)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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