我有一个Java存储过程,它使用Resultset对象从表中获取记录并创建一个csv文件.
BLOB retBLOB = BLOB.createTemporary(conn, true, BLOB.DURATION_SESSION);
retBLOB.open(BLOB.MODE_READWRITE);
OutputStream bOut = retBLOB.setBinaryStream(0L);
ZipOutputStream zipOut = new ZipOutputStream(bOut);
PrintStream out = new PrintStream(zipOut,false,"UTF-8");
out.write('\ufeff');
out.flush();
zipOut.putNextEntry(new ZipEntry("filename.csv"));
while (rs.next()){
out.print("\"" + rs.getString(i) + "\"");
out.print(",");
}
out.flush();
zipOut.closeEntry();
zipOut.close();
retBLOB.close();
return retBLOB;
Run Code Online (Sandbox Code Playgroud)
但生成的csv文件未显示正确的德语字符.Oracle数据库的NLS_CHARACTERSET值也为UTF8.
请建议.
我有一个用UTF32编码的CSV.当我在IE中打开流并用Excel打开时,我可以读取所有内容.在iPad上我流式传输,我得到一个没有任何内容的空白页面.(我不知道如何在iPad上查看源代码,因此HTML中可能存在隐藏的内容).
http响应是用asp.net C#编写的
Response.Clear();
Response.Buffer = true;
Response.ContentType = "text/comma-separated-values";
Response.AddHeader("Content-Disposition", "attachment;filename=\"InventoryCount.csv\"");
Response.RedirectLocation = "InventoryCount.csv";
Response.ContentEncoding = Encoding.UTF32;//works on Excel wrong in iPad
//Response.ContentEncoding = Encoding.UTF8;//works on iPad wrong in Excel
Response.Charset = "UTF-8";//tried also adding Charset just to see if it works somehow, but it does not.
EnableViewState = false;
NMDUtilities.Export oUtilities = new NMDUtilities.Export();
Response.Write(oUtilities.DataGridToCSV(gvExport, ","));
Response.End();
Run Code Online (Sandbox Code Playgroud)
我唯一猜到的是iPad无法读取UTF32,是真的吗?如何在iPad上查看来源?
iPad UTF8输出="Quattrode®"
Excel UTF8输出="Quattrode®"
iPad UTF32输出=""
Excel UTF32输出="Quattrode®"
这是我对DataGridToCsv的实现
public string DataGridToCsv(GridView input, string delimiter)
{
StringBuilder sb …Run Code Online (Sandbox Code Playgroud) 有没有办法从Ruby读取Excel 97-2003文件?
背景
我目前正在使用Ruby Gem parseexcel - http://raa.ruby-lang.org/project/parseexcel/ 但它是perl模块的旧端口.它工作正常,但它解析的最新格式是Excel 95.猜猜是什么?Excel 2007将不会生成Excel 95格式.
John McNamara已接任Perl Excel解析器的维护者职责,请参阅http://metacpan.org/pod/Spreadsheet::ParseExcel当前版本将解析Excel 95-2003文件.但是Ruby有一个端口吗?
我的另一个想法是构建一些Ruby to Perl粘合代码,以便从Ruby中使用Perl库本身.例如,请参阅将UTF8数据导出到Excel的最佳方法是什么?
(我认为编写粘合代码比移植解析器要快得多.)
谢谢,
拉里
我明白了
Quattrode®
Run Code Online (Sandbox Code Playgroud)
从HTML编码为的字符串
Quattrode®
Run Code Online (Sandbox Code Playgroud)
在Excel 2007中查看时.
常规
Response.Clear();
Response.Buffer = true;
Response.ContentType = "text/comma-separated-values";
Response.AddHeader("Content-Disposition", "attachment;filename=\"Expired.csv\"");
Response.RedirectLocation = "export.csv";
Response.Charset = "";
//Response.Charset = "UTF-8";//this does not work either.
EnableViewState = false;
ExportUtility util = new ExportUtility();
Response.Write(util.DataGridToCSV(gridViewExport, ","));
Run Code Online (Sandbox Code Playgroud)
基本上DataGridToCSV()使用 HttpUtility.HtmlDecode(stringBuilder.ToString());,我可以使用visual studio的文本可视化工具,看看字符串看起来正确(Quattrode®).
因此,Response过程或Excel对文件的解释中的某些内容不正确.知道怎么解决?