Java 在 CSV 文件中创建多个工作表

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22927124/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-13 19:04:57  来源:igfitidea点击:

Creating multiple sheets in CSV file

javacsvweb-development-serversupercsv

提问by user3363969

I am using superCSV to write data in csv format in my code. Its working absolutely fine and very efficiently , but now my requirement changed . I need to write multiple sheets in single xls file which is very time consuming task. So is there is any way in supercsv by which i can write multiple sheet data in single csv file and will send it to client, so that when client open this csv file in MS-Excel, he can see multiple sheets rather than me generating the excel file with with multiple sheets and sending it to client.

我正在使用 superCSV 在我的代码中以 csv 格式写入数据。它的工作非常好且非常有效,但现在我的要求发生了变化。我需要在单个 xls 文件中编写多个工作表,这是一项非常耗时的任务。那么在 supercsv 中有什么方法可以让我在单个 csv 文件中写入多个工作表数据并将其发送给客户端,这样当客户端在 MS-Excel 中打开这个 csv 文件时,他可以看到多个工作表而不是我生成带有多张表格的excel文件并将其发送给客户。

Thanks

谢谢

采纳答案by GreyBeardedGeek

CSV is a very simple format, and does not have the concept of a "sheet". So, no, it's not possible directly. The only thing that I can suggest is to send multiple csv files to the client, perhaps as a .zip file, and have the client unizp it and import one sheet at a time into Excel.

CSV 是一种非常简单的格式,没有“表格”的概念。所以,不,这是不可能直接的。我唯一可以建议的是将多个 csv 文件发送给客户端,可能是一个 .zip 文件,让客户端 unizp 并一次将一张工作表导入 Excel。

If you need it to open directly in the browser, you'll need to go with an xls file.

如果您需要直接在浏览器中打开它,则需要使用一个 xls 文件。

回答by nckbrz

Take a look at the api here.

看看这里的api。

http://supercsv.sourceforge.net/apidocs/index.html

http://supercsv.sourceforge.net/apidocs/index.html

I'm not familiar SuperCsv please don't beat me up too bad if I'm wrong... Can't you just set CsvPreferenceto EXCEL

我不熟悉 SuperCsv,如果我错了,请不要打我。你不能把CsvPreference设置为EXCEL