Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/372.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 生成csv格式时出现一些空行_Java_Jsp_Csv - Fatal编程技术网

Java 生成csv格式时出现一些空行

Java 生成csv格式时出现一些空行,java,jsp,csv,Java,Jsp,Csv,当生成csv格式时,我得到一些前12个空行,数据从第13行开始追加。请帮助我们如何忽略csv报告的前12行空行,数据应从第一行开始。下面是我的示例代码 if(excelParam.equals("csv")){ ServletOutputStream stream = response.getOutputStream(); StringBuffer stoppedTxnRowSB = new StringBuffer(); response.set

当生成csv格式时,我得到一些前12个空行,数据从第13行开始追加。请帮助我们如何忽略csv报告的前12行空行,数据应从第一行开始。下面是我的示例代码

if(excelParam.equals("csv")){
        ServletOutputStream stream = response.getOutputStream();
        StringBuffer stoppedTxnRowSB = new StringBuffer();
        response.setContentType("application/vnd.ms-excel; charset=UTF-8");
        response.setHeader("Content-Disposition","attachment; filename=\"sample.csv\"");
        response.addHeader("Content-description", reportTitle);
for(int i=0; i < reportHeader.length; i++){
            if(i ==  (samHead.length -1)){
                row.append(samHead[i] + "\n");
            }
             else{
                row.append(samHead[i]+", ");
            } 
        }
stream.print(stoppedTxnRowSB.toString());
        stream.flush();
        return;
if(excelParam.equals(“csv”)){
ServletOutputStream=response.getOutputStream();
StringBuffer stoppedTxnRowSB=新的StringBuffer();
response.setContentType(“application/vnd.ms-excel;charset=UTF-8”);
setHeader(“内容处置”、“附件;文件名=\”sample.csv\”);
addHeader(“内容描述”,reportTitle);
对于(int i=0;i
您用
stoppedTxnRowSB
填充输出流。您应该检查它。您的代码不完整。for循环用于什么?您用
stoppedTxnRowSB
填充输出流。您应该检查它。您的代码不完整。for循环用于什么?