将java文件转换为Excel电子表格

将java文件转换为Excel电子表格

本文介绍了将java文件转换为Excel电子表格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先感谢先前的帮助。
我想做的是以下。
是通过一个小程序来收集信息,这个程序可以用Java捕获并将其写入我已经完成的文件。
然后将此信息传递到预格式化的excel电子表格。
在电子表格中,它读取写入的数据,并将其显示在不同的表和图表中。
这是否可以自动编码或者我必须写到csv文件,从csv文件手动复制到excel模板?
如果任何人遇到了我的问题的解决方案,我会欣赏一个正确的方向。

解决方案

在servlet或JSP中的代码。
这将转换简单的excel表,您可以在其上进行进一步的操作。

  response.setContentType 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();
}

这里..

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

指定要生成的excel工作表。
all\t


。在您的需求基础上,您也可以使用数据库或任何...更改此代码。


First of all thanks for the previous help.What I want to do is the following.Is to collect information through a small program that can capture in Java and writes it to a file which I have done.Then to have this information passed to a preformatted excel spread sheet.In the spread sheet it reads this data that is written and displays it in different tables and graphs.Is this possible to automatically code or do I have to write to a csv file, from the csv file manually copy to an excel template?If anybody has come across a solution to my problem I would appreciate a steer in the right direction

解决方案

Hey try ths code in servlet or in JSP.This will convert simple excel sheet on which you can do 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" separates new cell in the excel sheet.

On your requirement basis you can also change this code with database or any...

这篇关于将java文件转换为Excel电子表格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-28 12:14