开发者

Need Dynamic/ default width for CSV file when EXPORTING through SERVLET

I am exporting my List to CSV file through Servlet. Everything is working fine. but i want to set default/ dynamic width for cell/column?

Here is my coding. Your swift reply will be helpful..

Thanks in advance.

package com.uson.stat.action;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class ExportAction extends HttpServlet {

        public void doPost(HttpServletRequest req, HttpServletResponse res)
                        throws ServletException, IOException  {

          res.setContentType("application/CSV");
          res.setHeader("Cache-Control", "public");
          res.setHeader("Pragma", "public");
          res.setHeader("Content-Disposition", "attachment;  filename= \"test.csv"+ "\"");

               String content = "Test Article"+","+"Viewed on 01-02-2010"+","+"Guest";

               System.out.println("content >>>>>>" + content);
           res.getOutputStream().print(content);
        }
}

output will be:

Test Article       Viewed on 01-01-2010      Guest

But output is displaying like this:

Test ArtiViewed on Guest

It is displaying fine in each cell. But I need to increase the size manually in Excel. file. How can i set the cel开发者_JS百科l width dynamically/default size?

How to resolve this?

  • Gnaniyar Zubair


"How can i set the cell width dynamically/default size?"

You can't.

CSV is just the data. Nothing more. No color, no font, no width. Nothing.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜