OleAutoObj objOleExcel= null OleAutoObj objOleExcelSheet = null OleAutoObj objOleExcelSheets = null OleAutoObj objOleCell = null OleAutoObj objOleColumn= null OleAutoObj objOleInterior=null OleAutoObj objOleBorders=null OleAutoObj objOle=null OleAutoObj objOleFont=null /* Purpose: set the size of a column and eventually wrap the text @param objExcelSheet: excel sheet @param i_Col: colomn @param size:column size, if 0 make the autofit @param b_aCapo: wrap the text */ void setColumnSize(OleAutoObj objExcelSheet,int i_col,int i_size, bool b_aCapo) { objOleColumn=null OleAutoArgs autoArgs = create put(autoArgs,i_col) oleGet(objExcelSheet,"Columns",autoArgs,objOleColumn) if (!( null objOleColumn )) { if (i_size==0) { oleMethod(objOleColumn, "AutoFit") } else { olePut(objOleColumn,"ColumnWidth",i_size) } olePut(objOleColumn,"WrapText",b_aCapo) } objOleColumn=null delete autoArgs } /* Purpose: set the background color for a cell @param objExcelCell: cell @param i_color: color */ void setBackgroundColours(OleAutoObj objExcelCell,int i_color) { objOleInterior=null oleGet(objExcelCell,"Interior",objOleInterior) olePut(objOleInterior,"Color",i_color) objOleInterior=null } /* Purpose: set the borders for a cell @param objExcelCell: cell @param bTop: insert top border @param bBottom: insert bottom border @param bLeft: insert left border @param bRight: insert right border */ void setCelBorders(OleAutoObj objExcelCell,bool bTop, bool bBottom, bool bLeft,bool bRight, int i_border) { const int xlEdgeRight=10 const int xlEdgeLeft=7 const int xlEdgeTop=8 const int xlEdgeBottom=8 const int xlContinuous=1 objOleBorders=null OleAutoArgs autoArgs = create if (bTop) { clear autoArgs put(autoArgs,xlEdgeTop) oleGet(objExcelCell,"Borders",autoArgs,objOleBorders) olePut(objOleBorders,"LineStyle ",xlContinuous) olePut (objOleBorders, "Weight", i_border) } if (bBottom) { clear autoArgs put(autoArgs,xlEdgeBottom) oleGet(objExcelCell,"Borders",autoArgs,objOleBorders) olePut(objOleBorders,"LineStyle ",xlContinuous) olePut (objOleBorders, "Weight", i_border) } if (bLeft) { clear autoArgs put(autoArgs,xlEdgeLeft) oleGet(objExcelCell,"Borders",autoArgs,objOleBorders) olePut(objOleBorders,"LineStyle ",xlContinuous) olePut (objOleBorders, "Weight", i_border) } if (bRight) { clear autoArgs put(autoArgs,xlEdgeRight) oleGet(objExcelCell,"Borders",autoArgs,objOleBorders) olePut(objOleBorders,"LineStyle ",xlContinuous) olePut (objOleBorders, "Weight", i_border) } delete autoArgs objOleBorders=null } /* Purpose: Mette in grassetto il testo di una cella @param objCell: cell */ void setBold(OleAutoObj objCell){ oleGet( objCell, "Font", objOleFont ) if ( null objOleFont ) return olePut( objOleFont, "Bold", true ) objOleFont=null } /* Purpose: write a value in a cell @param objExcelSheet: excel sheet @param sValue: value @param iRow: row @param iCol: column */ OleAutoObj writeCellValue(OleAutoObj objExcelSheet,string sValue, int iRow, int iCol, bool isBold) { objOleCell = null OleAutoArgs autoArgs = create put(autoArgs,iRow) put(autoArgs,iCol) oleGet(objExcelSheet,"Cells",autoArgs,objOleCell) if (!null objOleCell) { // Get the value olePut(objOleCell,"Value",sValue) delete autoArgs if (isBold) { setBold(objOleCell) } return objOleCell } delete autoArgs return null } /* Purpose: Insert a cell in a worksheet @param objExcelSheet: worksheet @param s_value: cell value @param i_row: row index @param i_col: column index @param b_heading: bold or not @param i_colsize: column size @param b_wrap: wrap the text @param b_borders: insert the borders @param i_backcolor: background color @param i_border: border width */ void InsertCell(string s_value,int i_row, int i_col, bool b_heading, int i_colsize, bool b_wrap, bool b_borders, int i_backcolor,int i_border) { objCell=writeCellValue (objExcelSheet,s_value,i_row,i_col,b_heading) if (!(i_colsize<0)) { setColumnSize(objExcelSheet,i_col,i_colsize,b_wrap) } setBackgroundColours(objCell,i_backcolor) setCelBorders(objCell,b_borders,b_borders,b_borders,b_borders,i_border) if (! null objCell) { objCell=null } }