Profile picture for user franciso_mota

Hello

I´m coding a script for excel spreadsheets and I require different styles for some of the cells.

This is my code:

var LenguaBd=Context.getSelectedLanguage();

var Modelos=ArisData.getSelectedModels();

var modelo= Modelos[0];

var sFileName = "MatrizPuestos.xls";

var sTemplateFileName = "PlantillaMatrizPuestos.xls";

var oXlsWorkbook = Context.createExcelWorkbook(sFileName, Context.getFile(sTemplateFileName, Constants.LOCATION_SCRIPT));

var oXlsSheet = oXlsWorkbook.getSheetAt(0);

var oXlsFont = oXlsWorkbook.createFont();

var oXlsStyle1=oXlsWorkbook.createCellStyle(oXlsFont, 0, 0, 0, 0, 0, 0, 0, 0, Constants.ALIGN_LEFT, Constants.ALIGN_CENTER, 0, 0, Constants.NO_FILL);

    oXlsStyle1.setFillPattern (Constants.SOLID_FOREGROUND );

    oXlsStyle1.setFillForegroundColor (Constants.C_GREY_80_PERCENT);

var oXlsStyle2=oXlsWorkbook.createCellStyle(oXlsFont, 0, 0, 0, 0, 0, 0, 0, 0, Constants.ALIGN_LEFT, Constants.ALIGN_CENTER, 0, 0, Constants.NO_FILL);

    oXlsStyle2.setFillPattern (Constants.SOLID_FOREGROUND);

    oXlsStyle2.setFillForegroundColor(Constants.C_LIGHT_BLUE);

   

    var oRow=oXlsSheet.createRow(0);

        var oCell = oRow.createCell(0);

        oCell.setCellValue("Niveles");

        oCell.setCellStyle(oXlsStyle1);

      

        oCell = oRow.createCell(1);

        oCell.setCellValue("Nombre Proceso");

        oCell.setCellStyle(oXlsStyle2);

   

   

    Context.setSelectedFile(sFileName);

    oXlsWorkbook.write();

why did the first style not used? I need a header, but the cells have no different background.

Any help would be appreciated.

by Torsten Haase
Posted on Mon, 04/28/2014 - 16:56

Hi Francisco,

you create exactly the same cell style twice. The workbook recognizes this and returns the same internal cell style object. To get different style objects, you have to specify different parameters calling XlsWorkbook#getCellStyle(). In your case this even makes your code easier:

var oXlsStyle1=oXlsWorkbook.createCellStyle(oXlsFont, 0, 0, 0, 0, 0, 0, 0, 0, Constants.ALIGN_LEFT, Constants.ALIGN_CENTER, 0, Constants.C_GREY_80_PERCENT, Constants.SOLID_FOREGROUND);

var oXlsStyle2=oXlsWorkbook.createCellStyle(oXlsFont, 0, 0, 0, 0, 0, 0, 0, 0, Constants.ALIGN_LEFT, Constants.ALIGN_CENTER, 0, Constants.C_LIGHT_BLUE, Constants.SOLID_FOREGROUND);



BR, Torsten

0
by francisco mota aleman Author
Posted on Mon, 04/28/2014 - 18:20

In reply to by thaase

Hi Torsten,

I made what you told me and It works

thanks a lot

0

Featured achievement

Rookie
Say hello to the ARIS Community! Personalize your community experience by following forums or tags, liking a post or uploading a profile picture.
Recent Unlocks

Leaderboard

|
icon-arrow-down icon-arrow-cerulean-left icon-arrow-cerulean-right icon-arrow-down icon-arrow-left icon-arrow-right icon-arrow icon-back icon-close icon-comments icon-correct-answer icon-tick icon-download icon-facebook icon-flag icon-google-plus icon-hamburger icon-in icon-info icon-instagram icon-login-true icon-login icon-mail-notification icon-mail icon-mortarboard icon-newsletter icon-notification icon-pinterest icon-plus icon-rss icon-search icon-share icon-shield icon-snapchat icon-star icon-tutorials icon-twitter icon-universities icon-videos icon-views icon-whatsapp icon-xing icon-youtube icon-jobs icon-heart icon-heart2 aris-express bpm-glossary help-intro help-design Process_Mining_Icon help-publishing help-administration help-dashboarding help-archive help-risk icon-knowledge icon-question icon-events icon-message icon-more icon-pencil forum-icon icon-lock