ARIS Community - We Love BPM

How to hide cells in Excel output

snguyen's picture
by Sam Nguyen in Reports & Macros posted on 2012-03-26

Hi there,

I am trying to make a cell in an Excel workbook hidden or locked but once got the output, I still could see and edit the cell in the output file. I was not sure if I had missed something. Below is my hopeless code.

Any idea would be most appreciated

Regards,

Sam

var oExcelWorkbook = Context.createExcelWorkbook("myexcel.xls");
//
var oSheet = oExcelWorkbook.createSheet("mysheet");
var oHeaderSet = oSheet.createRow(0);       

var oCell = oHeaderSet.createCell(i);
oXlsCellStyle = oCell.getCellStyle();
oXlsCellStyle.setAlignment(Constants.ALIGN_CENTER);
oXlsCellStyle.setHidden(true);
oXlsCellStyle.setLocked(true);
oCell.setCellStyle(oXlsCellStyle);
oCell.setCellValue("ABC");
oExcelWorkbook.write();

 

910 Views
0 Likes
3 Comments
Sorry there are no tags
There are no attachments
edwv's picture
by Edwin Verstraeten posted on 2012-03-26

Hi Sam,

I can't tell about your version of excel, but in mine you first have to lock the the sheet before these settings have effect.....

Best regards,

Edwin

snguyen's picture
by Sam Nguyen posted on 2012-03-26

Thanks Edwin for your feedback.

My excel version is 2007. Could you be a bit more specific on how to lock the sheet in ARIS script?. I went through all of the methods of the XlsSheet object and could not seem to see a relevant method doing this.

Thanks,

Sam

edwv's picture
by Edwin Verstraeten posted on 2012-03-27

Hi Sam,

You can use the method XlsSheet.setPasswordProtect(<password>).

If you don't need the password, you can use "", but then the end user can unprotect the sheet without password.

Success,

Edwin