Free Support Forum - aspose.com

Workbook.save doesnot preserve existing TextBox and chart in the excel file

Hi,

Please run the following sample and see that the saved copy of excel doesn’t keep TextBox and chart in the actual excel file. Please use the attached excel file as input, which contains TextBox and chart.

import java.io.FileOutputStream;
import com.aspose.cells.CellsHelper;
import com.aspose.cells.Workbook;

public class OpenExcelWithTextBox {
public static void main(String args[]) {
try {
Workbook wb = new Workbook();
wb.loadData("D:\\Temp\\output.xls");
wb.save(new FileOutputStream("D:\\Temp\\output_copy.xls"));
System.out.println("successfully completed!!!" + CellsHelper.getReleaseVersion());
}
catch (Exception e) {
e.printStackTrace();
}
}
}

Thanks
Muhammed

Hi,

Please use Workbook.open method instead of Workbook.loadData() method.

i.e.,

Workbook wb = new Workbook();
wb.open(“D:\Temp\output.xls”);
wb.save(new FileOutputStream(“D:\Temp\output_copy.xls”));
System.out.println(“successfully
completed!!!” +
CellsHelper.getReleaseVersion());



For your information, when you use Workbook.loadData method, all the drawing objects, shapes, formatting etc would be lost, only the data would be retrieved though.


Thank you.