How to create read_only Excel file in Java

hello
In my project i want create a read_only excel by using java code when we r writting .we alread wrote to create a file by using “hssfworkbook” but it is not secured any one can change it and we also tryed ur example wht u have sugested to others but in my proj even we r unable to create the instance (error:u cant create instance for workbook)for ur example.so plz sugest for who to create read only excel file using “hssfworkbook”.if it is not posible plz u can sugest any other example but plz provide me the packge r jar files to impliment it.


Hi,

Well, I think you are using POI - HSSF component. To use Aspose.Cells component, you need to have its jar file(s). Please download it @: http://www.aspose.com/community/files/51/file-format-components/aspose.cells-for-.net-and-java/entry169973.aspx To use the APIs of the component you need to set and add to its classpath for your java environmental variables or use some editors of java like Eclipse.

Or you may set it at runtime at dos prompt in winxp.

e.g.

javac -classpath %classpath%;e:\Aspose.Cells.jar; TestCls.java
java -classpath %classpath%;e:\Aspose.Cells.jar; TestCls

Sample Program:

......................

import com.aspose.cells.*;

.................

Workbook workbook = new Workbook();

workbook.open("E:\\Files\\inputfile.xls");

Worksheet worksheet = workbook.getWorksheets().getSheet(0);

Cells cells = worksheet.getCells();

Cell cell = cells.getCell("D1");

cell.setValue("HelloWorld!");

workbook.save("E:\\Files\\output.xls");

For creating read-only spreadsheets, I think you may protect sheets, please see the following documentation topics for reference:

Kindly let us know if you need further clarifications, we would be glad helping you soon.

Thank you.