合并单元格使用EPPlus? [英] Merge cells using EPPlus?

查看:5198
本文介绍了合并单元格使用EPPlus?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的EPPlus库读取/写入Excel文件: HTTP://epplus.$c$cplex.com/

I'm using the EPPlus library to read/write Excel files: http://epplus.codeplex.com/

我试图写一个文档时,简单地合并一些细胞:

I'm trying to simply merge some cells when writing a document:

using (ExcelPackage pck = new ExcelPackage())
{
    //Create the worksheet
    ExcelWorksheet ws = pck.Workbook.Worksheets.Add("Demo");

    //Format the header for column 1-3
    using (ExcelRange rng = ws.Cells["A1:C1"])
    {
        bool merge = rng.Merge;
    }
}

有一个属性命名合并只返回true或false。我想,也许这将合并单元格,但事实并非如此。

There's a property named Merge that simply returns true or false. I thought maybe that would Merge the cells, but it doesn't.

任何人都知道如何做到这一点?

Anyone know how to do this?

推荐答案

您必须使用它是这样的:

You have to use it like this:

ws.Cells["A1:C1"].Merge = true;

而不是:

using (ExcelRange rng = ws.Cells["A1:C1"])
{
    bool merge = rng.Merge;
}

这篇关于合并单元格使用EPPlus?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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