如何使用C#将xls文件转换为xlsx文件? [英] How to convert xls file to xlsx file using C#?

查看:1883
本文介绍了如何使用C#将xls文件转换为xlsx文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个应用程序,该应用程序从excel文件中读取数据,但是当我尝试打开它时,如果源文件以 xls格式保存,则会引发异常(文件包含损坏的数据使用OpenXML打开Excel工作表时出现错误).确实,当我以xlsx格式保存此文件时,它可以正常工作.请帮助我解决这个问题.

I was developing an application which read data from an excel file, but when I try to open it, an exception  was thrown if the source file is saved with the xls format (File contains corrupted data error when opening Excel sheet with OpenXML). indeed when I save this file with the xlsx format it works fine. please help me to solve this problem.

推荐答案

使用可通过 NuGet .

示例:

Workbook workbook = new Workbook();
workbook.LoadFromFile("Input.xls");
workbook.SaveToFile("Output.xlsx", ExcelVersion.Version2013);

这篇关于如何使用C#将xls文件转换为xlsx文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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