本文介绍了EPPlus - 如何使用模板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近发现了EPPlus()。
我的项目中有一个excel .xlsx文件,其中包含所有样式的列标题。
我在他们的网站上看到你可以使用模板。

I have recently discovered EPPlus (http://epplus.codeplex.com/).I have an excel .xlsx file in my project with all the styled column headers.I read on their site that you can use templates.

有谁知道如何或可以提供如何使用我的template.xlsx文件与EPPlus的代码示例?我想能够简单地将我的数据加载到行中,而不会弄乱标题。

Does anyone know how or can provide code sample of how to use my template.xlsx file with EPPlus? I would like to be able to simply load my data into the rows without messing with the headings.

推荐答案

解决方案我结束了使用:

The solution I ended up going with:

using System.IO;
using System.Reflection;
using OfficeOpenXml;

//Create a stream of .xlsx file contained within my project using reflection
Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("EPPlusTest.templates.VendorTemplate.xlsx");            

//EPPlusTest = Namespace/Project
//templates = folder
//VendorTemplate.xlsx = file

//ExcelPackage has a constructor that only requires a stream.
ExcelPackage pck = new OfficeOpenXml.ExcelPackage(stream);

之后,您可以使用所需的所有ExcelPackage方法在.xlsx文件中加载模板。

After that you can use all the methods of ExcelPackage that you want on an .xlsx file loaded from a template.

这篇关于EPPlus - 如何使用模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-20 18:16