Can someone show me a C# example of how to properly use the easy_insertColumn command?
Mon Aug 07, 2017 2:04 pm
daniela
Joined: Fri Feb 03, 2006 12:23 pm Posts: 199 Location: Brasov, Romania
Re: easy_insertColumn example?
easy_insertColumn method inserts an ExcelColumn object. ExcelColumn class stores only the column formatting:
Code:
//Set the worksheet where you need to add the column ExcelWorksheet xlsWorksheet = (ExcelWorksheet)xls.easy_getSheetAt(0); ExcelTable xlsTable = xlsWorksheet.easy_getExcelTable();
//Create the new column (the column stores only the formatting, not the data) int nNewColumnIndex = 1; ExcelColumn xlsNewColumn = new ExcelColumn(); xlsNewColumn.setWidth(200);//optional xlsTable.easy_insertColumn(nNewColumnIndex, xlsNewColumn);
If you also need to insert the column cells, you will need this extra code:
Code:
//Add data for the new column ExcelCell xlsNewValue; for (int nRow=0; nRow<xlsTable.RowCount(); nRow++) { xlsNewValue = new ExcelCell(); xlsNewValue.setValue("new value for row " + (nRow+1)); xlsTable.easy_getRowAt(nRow).easy_insertCellAt(xlsNewValue, nNewColumnIndex); }
Users browsing this forum: No registered users and 1 guest
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot post attachments in this forum