I'm trying to create Excel file in java. Right now, i'm using Apache POI library to create the file and save it to local drive. Is there a way to start up excel and populate the data without saving it to hard drive?
Asked
Active
Viewed 1,036 times
2 Answers
1
Consider the approach shown in Downloading Excel file from server using servlets. I've used it for CSV files, but the xlsx
mime type extension looks appealing.
-
i want to assemble the file on client side instead. – Progress Programmer Oct 26 '11 at 02:50
-
@PP - From the server? You say you're using POI so I'm guessing that's where your code is running. How would you do that? – Tim Williams Oct 26 '11 at 03:58
-
i'm assembling the file at client side using applet. Dont really want to have another trip to server to get the data. – Progress Programmer Oct 26 '11 at 06:36
0
Something like this maybe
import java.awt.Desktop;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
public class ManualXlsxTest {
public static void main(String[] args) throws FileNotFoundException, IOException {
Workbook wb = new XSSFWorkbook();
wb.createSheet("new sheet");
File tempXlsx = File.createTempFile("temp", ".xlsx");
wb.write(new FileOutputStream(tempXlsx));
Desktop.getDesktop().open(tempXlsx);
}
}

Ivan Sopov
- 2,300
- 4
- 21
- 39