I am getting huge data from database approx a million and trying to store it using csv format in excel like :
response.setContentType("application/ms-excel");
response.setHeader("Content-Disposition", "inline;filename=newfile.csv");

but as the data is huge and excel can take only 65K at one time its failing.

Please let me know how to download data in multiple excel files at one go....

The data download for your newfile.csv, doesn't fail, it is downloaded, try opening that file via notepad or some other text editor and you should get have all the data in it (even if the file has more than 65535 rows), the problem is with 'MS Excel', it cannot handle more than 65k rows.
If you have to use 'MS Excel' to view or manipulate your data then in that case take a look at the Apache POI and write your data into an XLS format (Currently you are using the good ol' comma-separated-version CSV), and use multiple sheets to store your data in case it exceeds 65535 rows.

Note:-
XLS is the name of the extension used when you save the file in Excel '97(-2007) format. The formal format name my guess is BIFF8

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.