简体   繁体   中英

How can I export data from Java to Excel or Word if documents have different forms?

I need to know how to export data from Java to Excel. My customer gave me a form and asked me export the data to their report form. They can give me a different form. How can I do this?

I need to know how to export data from Java to Excel.

Easiest way is to create a comma separated values (csv) file, which you import into Excel.

My customer gave me a form and asked me export the data to their report form.

Hard to say without seeing the form, but you can copy values from the Excel csv page to the report form page within the same Excel workbook. You could automate this with a Visual Basic script.

They can give me a different form.

And you can copy values from the Excel csv page to the new report form page within the same Excel workbook. You could automate this with another Visual Basic script.

看看Apache POI

You might look into using the Apache POI library (http://poi.apache.org/). The library was created with the sole intent of reading and writing Office Open XML standards (OOXML) and Microsoft's OLE 2 Compound Document format (OLE2).

Can you assume presence of Open Office or MS Office on System?

Best way to do that would be via Mail merge. Setup a mail merge template and provide data in an excel/csv file from java program.

Once dta has been generated, formatted reports can be generated via mail merge. And since its template, it can be very easily be modified in Office itself.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM