Hi Yegor,
We are gaining a lot of grounds in efforts of transitioning to the latest
poi-3.5 in order to support .xlsx formats. One of the core requirements
from our application/client is to password protect the final output
workbook.
I know you've mentioned that the final version will be released sometime
soon (Oct). Do you for-see this functionality being included to that
version?
Thanks.
Yegor Kozlov wrote:
>
> writeProtecWorkbook() is XSSF is not yet supported.
>
> Yegor
>> In respect to the subject, does anyone know why writeProtecWorkbook()
>> method
>> is not supported within the XSSFWorkbook API ? Is there an alternative
>> way
>> to password 'lock' the workbook with the XSSF format? Or is it that the
>> method hasn't been implemented yet ?
>>
>> Thanks.
>>
>>
>>
>> Debendra wrote:
>>> Hi Mark,
>>> If I uncomment the statement sheet.protectSheet("xyz"); then it does not
>>> allow to modify the excel sheet but it does not ask any password to open
>>> the excel file. It is not prompting any password while opening the excel
>>> file, but my requirement is it should ask password to open the excel
>>> file.
>>> The excel file will not be opened without any password. Could you please
>>> help me to solve this issue.
>>>
>>> Thanks,
>>> Debendra
>>>
>>>
>>> MSB wrote:
>>>> I think that I am correct in saying that there are two parts to this
>>>> equation, cell is locking and protection; unless cells are locked then
>>>> protection will not be enabled.
>>>>
>>>> The easy wasy to test this hypotheses is to modify the cell style you
>>>> are
>>>> creating in the attached code and add this line;
>>>>
>>>> cs.setLocked(true);
>>>>
>>>> apply the cell style as you are now and uncomment the
>>>> protectSheet("xyz")
>>>> line;
>>>>
>>>> sheet.protectSheet("xyz");
>>>>
>>>> I think that will solve the problem but cannot be absolutely certain;
>>>> either way, it is certainly worth checking.
>>>>
>>>> Yours
>>>>
>>>> Mark B
>>>>
>>>>
>>>> Debendra wrote:
>>>>> Hi,
>>>>> Could anyone please help me to create a password protected excel
>>>>> sheet.
>>>>> The requirement is, password needs to be given to open an excel file.
>>>>> It
>>>>> will not open the excel file without password. I am using the
>>>>> following
>>>>> program, but it is not asking any password while opening.
>>>>>
>>>>> import java.io.;
>>>>> import org.apache.poi.hssf.usermodel.;
>>>>> class PasswordExcelSheet {
>>>>> public static void main(String arg[]) {
>>>>> try{
>>>>> FileOutputStream out = new
>>>>> FileOutputStream("D:\\java_prog\\excelsheet\\MyExcel.xls");
>>>>> HSSFWorkbook hssfworkbook = new HSSFWorkbook();
>>>>> hssfworkbook.writeProtectWorkbook("abc","xyz");
>>>>> HSSFSheet sheet = hssfworkbook.createSheet("new sheet");
>>>>> String s="HCL Tech";
>>>>> HSSFCellStyle cs = hssfworkbook.createCellStyle();
>>>>> HSSFDataFormat df = hssfworkbook.createDataFormat();
>>>>> HSSFFont f = hssfworkbook.createFont();
>>>>> HSSFFont f2 = hssfworkbook.createFont();
>>>>> cs.setDataFormat(HSSFDataFormat.getBuiltinFormat("text"));
>>>>> HSSFRow row = sheet.createRow((short)0);
>>>>> HSSFCell cell = row.createCell((short)0);
>>>>> cell.setCellValue(s );
>>>>> cell.setCellStyle(cs);
>>>>> //sheet.protectSheet("xyz");
>>>>> hssfworkbook.write(out);
>>>>> out.close();
>>>>> }
>>>>> catch(Exception e){
>>>>> System.out.println("Error : "+e);
>>>>> }
>>>>> }
>>>>> }
>>>>>
>>>>
>>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>
>
--
View this message in context:
http://www.nabble.com/writeProtectWorkbook%28%29-method-does-not-work-to-set-password-to-excel-file-to-open-tp25447832p25454471.html
Sent from the POI - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]