Convert java file to Excel

First of all, thanks for the previous help. I want to do the following. Collect information through a small program that can capture in Java and write it to a file that I made. Then, to transfer this information to a pre-formatted Excel distribution sheet. In an expanded sheet, he reads this data, which is recorded and displayed in different tables and graphs. Is it possible to automatically encode or the need to write to the csv file from the csv file manually copied to the excel template? If anyone came across a solution to my problem, I would appreciate a guide in the right direction.

0
source share
2 answers

Hey, try the code in the servlet or in the JSP. This converts a simple excel sheet on which you can perform further operations.

response.setContentType("application/vnd.ms-excel"); PrintWriter out = response.getWriter(); try { out.println("\tId \tName"); out.println("\t1\tabc"); out.println("\t2\txyz"); out.println("\t3\tpqr"); } finally { out.close(); } 

here.

 response.setContentType("application/vnd.ms-excel"); 

specify the excel sheet to be generated. all "\ t" separate the new cell in the excel sheet.

At your request, you can also change this code using a database or any ...

+1
source

This is a duplicate. How to read and write excel file in java

you can use this API: http://poi.apache.org/

Or, if you write a single text file with tab delimiter between fields and save with the extension (.XLS), excel should read it. But of course, the best solution is to use Apache POI HSSF.

0
source

Source: https://habr.com/ru/post/1480658/


All Articles