NPOI.Core

该项目是POI Java项目的.NET Core版本。 使用NPOI,您可以非常轻松地读取/写入Office 2003/2007文件。

NPOI Core here, NPOI elsewhere

该项目适用于NPOI CoreNPOI仍处于 https://github.com/tonyqus/npoi

What is NPOI Core?

NPOI CoreNPOI.NET Core版本。

AssemblyModule/NamespaceSummary
Npoi.Core.dllNpoi.Core.POIFSOLE2/ActiveX文档属性读写库
Npoi.Core.dllNpoi.Core.DDFMicrosoft Office Drawing读写库
Npoi.Core.dllNpoi.Core.HPSFOLE2/ActiveX文档读写库
Npoi.Core.dllNpoi.Core.HSSFMicrosoft Excel BIFF(Excel 97-2003)格式读写库
Npoi.Core.dllNpoi.Core.SSExcel公用接口及Excel公式计算引擎
Npoi.Core.dllNpoi.Core.Util基础类库,提供了很多实用功能,可用于其他读写文件格式项目的开发
Npoi.Core.OOXML.dllNpoi.Core.XSSFExcel 2007(xlsx)格式读写库
Npoi.Core.OOXML.dllNpoi.Core.XWPFWord 2007(docx)格式读写库
Npoi.Core.OpenXml4Net.dllNpoi.Core.OpenXml4NetOpenXml底层zip包读写库
Npoi.Core.OpenXmlFormats.dllNpoi.Core.OpenXmlFormats微软Office OpenXml对象关系库

Getting Started

Export Excel
var newFile = @"newbook.core.xlsx";
using (var fs = new FileStream(newFile, FileMode.Create, FileAccess.Write)) {
    IWorkbook workbook = new XSSFWorkbook();
    ISheet sheet1 = workbook.CreateSheet("Sheet1");
    sheet1.AddMergedRegion(new CellRangeAddress(0, 0, 0, 10));
    var rowIndex = 0;
    IRow row = sheet1.CreateRow(rowIndex);
    row.Height = 30 * 80;
    row.CreateCell(0).SetCellValue("this is content, very long content, very long content, very long content, very long content");
    sheet1.AutoSizeColumn(0);
    rowIndex++;
    var sheet2 = workbook.CreateSheet("Sheet2");
    var style1 = workbook.CreateCellStyle();
    style1.FillForegroundColor = HSSFColor.Blue.Index2;
    style1.FillPattern = FillPattern.SolidForeground;
    var style2 = workbook.CreateCellStyle();
    style2.FillForegroundColor = HSSFColor.Yellow.Index2;
    style2.FillPattern = FillPattern.SolidForeground;
    var cell2 = sheet2.CreateRow(0).CreateCell(0);
    cell2.CellStyle = style1;
    cell2.SetCellValue(0);
    cell2 = sheet2.CreateRow(1).CreateCell(0);
    cell2.CellStyle = style2;
    cell2.SetCellValue(1);
    workbook.Write(fs);
}
Export Word
var newFile2 = @"newbook.core.docx";
using (var fs = new FileStream(newFile2, FileMode.Create, FileAccess.Write)) {
    XWPFDocument doc = new XWPFDocument();
    var p0 = doc.CreateParagraph();
    p0.Alignment = ParagraphAlignment.CENTER;
    XWPFRun r0 = p0.CreateRun();
    r0.FontFamily = "microsoft yahei";
    r0.FontSize = 18;
    r0.IsBold = true;
    r0.SetText("This is title");
    var p1 = doc.CreateParagraph();
    p1.Alignment = ParagraphAlignment.LEFT;
    p1.IndentationFirstLine = 500;
    XWPFRun r1 = p1.CreateRun();
    r1.FontFamily = "·ÂËÎ";
    r1.FontSize = 12;
    r1.IsBold = true;
    r1.SetText("This is content, content content content content content content content content content");
    doc.Write(fs);
}
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值