EPPlus - 如何使用模板 [英] EPPlus - How to use a template

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

问题描述

我最近发现EPPlus( http://epplus.codeplex.com/ )。
我已经在我的项目的所有风格的列标题的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);



之后,你可以使用你想在从加载的.xlsx文件的ExcelPackage的所有方法模板。

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

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

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