在c#中使用EPPlus应用样式时Excel文件大小增加 [英] Excel file size inceases on applying styles using EPPlus in c#

查看:297
本文介绍了在c#中使用EPPlus应用样式时Excel文件大小增加的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用EPPlus将数据表导出到excel文件,并在导出之前为某些单元格范围应用样式。由于样式,文件大小急剧增加到5 MB。当我导出相同而不应用任何样式时,其大小为400 kb。问题是什么??它的解决方案是什么?

解决方案

问题是你正在嵌入EEPlus中的样式。对于字体,这些字体文件不位于C:\ Windows \ system或C:\ Windows \ System32位置中的FONT FILES。可能是EEPlus提供的样式字体是专有的,需要嵌入才能显示它们。如果您可以在加载之前加载/应用样式文件(比如在某些类型的批处理文件中)实际的excel工作簿文件,那么您的文件将更小,或者如果其他人需要查看它们,则安装它们(样式文件) excel文件所在系统上的任何支持DLL。


没有足够的信息来回答这个有点模糊的问题。如果Excel支持* .xlsx文件,则可以研究该问题。此格式基于XML并使用ZIP算法打包。因此,您可以解压缩文件(为此,您可能需要将* .xlsx重命名为* .zip)并研究和比较它们的内容。您可以特别使用Visual Studio的XML查看器或任何其他文件比较工具等。



-SA

I am exporting a datatable to an excel file using EPPlus and the applying styles for some range of cells before exporting.Because of the styles, the file size increases drastically to 5 MB. When I export the same without applying any styles its size is 400 kb. What is the problem?? and what is its solution?

解决方案

The problem is that you are 'embedding' the styles from the EEPlus. These FONT FILES are not located with the FONT FILES in the C:\Windows\system or C:\Windows\System32 locations for fonts. It may be that the style fonts provided by EEPlus are proprietary, and need to be embedded in order for them to be displayed at all. If you can load/apply the style files prior to loading (like in a batch file of some sorts) the actual excel workbook file, then your file will be smaller, or if someone else needs to see them, then install them (style files and any supporting DLLs) on the system where the excel file is going.


Not enough information to answer this somewhat vague question. You can research the problem if your Excel supports *.xlsx files. This format is XML based and packed using ZIP algorithm. So, you can unpack the files (for this purpose, you may need to rename "*.xlsx" to "*.zip") and study and compare their content. You can use, in particular, XML viewers of Visual Studio or any other, some file comparison tools, etc.

—SA


这篇关于在c#中使用EPPlus应用样式时Excel文件大小增加的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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