Removing data from multiple excel files - java

I have two excel files. There is some common data in both the files. I want to get a new excel file which only has non redundant data. I am reading data from excel files using apace POI (Java). Any help on the algorithm that can be used to remove the redundant data (since there are more than 10,000 rows in each excel file). Thanks.

copy all the data in HashSet(). and write it in another file.

Related

Creating multiple sheets in CSV file

I am using superCSV to write data in csv format in my code. Its working absolutely fine and very efficiently , but now my requirement changed . I need to write multiple sheets in single xls file which is very time consuming task. So is there is any way in supercsv by which i can write multiple sheet data in single csv file and will send it to client, so that when client open this csv file in MS-Excel, he can see multiple sheets rather than me generating the excel file with with multiple sheets and sending it to client.
Thanks
CSV is a very simple format, and does not have the concept of a "sheet".
So, no, it's not possible directly.
The only thing that I can suggest is to send multiple csv files to the client, perhaps as a .zip file, and have the client unizp it and import one sheet at a time into Excel.
If you need it to open directly in the browser, you'll need to go with an xls file.
Take a look at the api here.
http://supercsv.sourceforge.net/apidocs/index.html
I'm not familiar SuperCsv please don't beat me up too bad if I'm wrong...
Can't you just set CsvPreference to EXCEL

Reading large xls files(having 7-8 sheets with each having 30-40,000 rows ) in java

Is there a way to read large xls files?
I have used Apache POI to read files but only till some limit.
I have a database which has some data and now I want to upload a file of large size (like i told). This file contains little more data in one of its sheets as compare to the data that database has. now how should i update that data in oracle database without setting up the xls file.
For large xls files you should use the streaming extension of XSSF, called SXSSF. It should be able to handle your requirements without memory problems.
As for the database problem: I'd suggest you read the xls files using XSSF and create temporary tables for each file in the database (depending on your needs). Once all the rows are stored in temp tables you can easily merge them with your existing data.

How to get the values from DB and store it in a existing excel file using java?

I want to store the values from the database to an existing excel file. For example if the file is stored in C: data.xls. I want the data from db table to be stored in that.
I will mention the column name in the excel file itself.
Please help me to do this.
Use JDBC API to read/fetch result from the MySql database and jExcelAPI or Apache POI (recommended) to write/update excel document.
Writing to a CSV file is probably the easiest way to do this. CSV files can be opened up in Excel, but cannot have any text formatting. See the CSV Wikipedia article for more details on the format.
If you would rather use an XLS or XLSX format, consider using Apache POI, as the formats of those file types (particularly XLS) is quite complicated to write to manually.
If you are going for a CSV file, you need only open the file, and begin putting rows, one per line, with commas in between values. It's very simple, and works with a variety of software.

Is there any API that takes an Excel file and converts it to a CSV file using Java?

I have 200,000 or more records in an Excel file. If I tried to read records row by row and create a CSV file it's very costly as well as time consuming. Is there any API that can help me with that?
There are several frameworks out there, if you have a look.
For example, you can try:
Apache POI (example)
JExcel (example)
This seems to be the same question as How to import an Excel file into MySQL using ODBC in Java?
What has changed? If you want to write to a CSV file you should use a CSV library such as OpenCSV: http://opencsv.sourceforge.net/

import .xls files to mysql in java servlet

I have a folder of 300+ xls files. The structure of this files is the same, but data is different. So I need to import this data to mysql table using servlets.
I think there are few stages:
Load a folder with files to server
Convert files to .csv
Import files one by one to mysql
But how can I implement this mechanism technically using servlets?
Thanks
First convert Xls to csv using this:
http://permalink.gmane.org/gmane.comp.jakarta.poi.user/14301
Then Import the csv using this:
http://www.javalobby.org/java/forums/t53674.html
using apache poi you can easily read any number of xls file.
link :http://poi.apache.org/
To insert it into database it is not required to convert it into .csv. You can read each cell of each file .Since each file's structure is same a List of DTO formed by storing all value of you excel sheet can be directly inserted into database.
You can get started at http://poi.apache.org/spreadsheet/quick-guide.html
Best of Luck

Categories

Resources