How to hide cells in Excel output

Translate this pagebookmark or share this page
Sam's picture

Posted: 2012-03-26
593 views | 3 comments | category: ARIS Community

0
show all articles

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();

 

Comments
Edwin's picture

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

Sam's picture

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

Edwin's picture

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