简体   繁体   English

将CSV文件转换为XLS时的问题

[英]Issues in converting CSV file in to XLS

Hi all I want to convert a CSV file in to .xlsx file I write the .xls file like below. 大家好,我想将CSV文件转换为.xlsx文件,我写如下的.xls文件。

        InputStream in = new FileInputStream("csvpath");
        OutputStream out = new FileOutputStream("xlsPath");
        byte[] buf = new byte[1024];
        int len;
        while ((len = in.read(buf)) > 0) {
            out.write(buf, 0, len);
        } 

but the resultant .xls file is having file in opening. 但是生成的.xls文件正在打开文件。 Is there any specific type of code to do this? 是否有任何特定类型的代码可以执行此操作?

So is there any problem here and any suggestion to do this? 那么这里有什么问题和建议吗?

Please try to give suggestion in java only not any third party. 请尝试仅在Java中提供建议,而不是任何第三方。

CSV is just a text file which contains values separeted by Comma, that is why it is called csv(Comma Separated Values).If you want conversation, you will need to use apache poi library for this. CSV只是一个文本文件,其中包含用逗号分隔的值,这就是为什么它称为csv(逗号分隔值)的原因。如果要进行对话,则需要使用apache poi库进行此操作。

You will find below link usefull for the same 您将在以下链接中找到同样有用的链接

http://poi.apache.org/ http://poi.apache.org/

https://poi.apache.org/apidocs/ https://poi.apache.org/apidocs/

Hope this helps :) 希望这可以帮助 :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM