I am trying to edit inside a .xls file using Apache poi library. All the updation is succesfull on local computer.But, i am stuck when jar file of application does not saved excel file on computer on which it is installed.
FileChooser fileChooser = new FileChooser();
fileChooser.setTitle("Generated data of Dvat ");
fileChooser.setTitle("Generate XLS File of " + "Dvat 31");
fileChooser.getExtensionFilters().addAll(
new ExtensionFilter("XLS Files", "*.xls"));
fileChooser.setInitialFileName(Common
.replaceWhiteSpaceAndSlash("Dvat31")
+ "_"
+ Common.replaceWhiteSpaceAndSlash(Common.comp.getName()+"_")
+this.fromdate+"_"+this.todate+ ".xls");
fileChooser.setInitialDirectory(new File(System
.getProperty("user.home") + "/Desktop"));
File selectedFileName = fileChooser.showSaveDialog(null);
if(selectedFileName!=null)
{
String fileName=absolutePath;
HSSFWorkbook wb = HSSFReadWrite.readFile(fileName);
FileOutputStream stream = new FileOutputStream(selectedFileName.getAbsolutePath());
// Updation On .xls Sheet.
row = sheet.getRow(34);
for(int i=1;i<=12;i++)
{
if(i==4)
{
cell=row.getCell(i);
cell.setCellValue(this.consignmentTotal);
}
}
// Closing workbook and outputstream.
wb.write(stream);
stream.close();
wb.close();
