转换的Excel文件从.csv格式的.xlsx [英] Converting Excel File From .csv To .xlsx

查看:151
本文介绍了转换的Excel文件从.csv格式的.xlsx的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想我的应用程序去找到一个 CSV excel文件,并将其转换成一个.xlsx文件,而不是

I want my application to go and find a csv excel file and convert it into a .xlsx file instead.

下面是目前我在做什么;

Here's what I'm currently doing;

var fileName = @"Z:\0328\orders\PurchaseOrder.csv";
FileInfo f = new FileInfo(fileName);
f.MoveTo(Path.ChangeExtension(fileName, ".xlsx"));
var Newfile = @"Z:\0328\orders\PurchaseOrder.xlsx";

现在这个确实工作。它改变文件扩展名来我所需的格式。但是,该文件随即成为'腐败',或者至少Excel中拒绝打开它,都不会对我的应用程序,当我试图进一步冒险。

Now this does work. It changes the file extension to my desired format. However, the file then become 'corrupt' or at least Excel refuses to open it and neither will my application when I try to venture further.

有没有人有一个解决方案/ ?解决方法

Does anyone have a solution/work-around?

推荐答案

我会解析CSV文件并使用它来写出一个Excel文件:的http://epplus.codeplex.com/

I would parse in the CSV file and use this to write out an Excel file : http://epplus.codeplex.com/

这篇关于转换的Excel文件从.csv格式的.xlsx的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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