EasyXLS
http://forum.easyxls.com/

easy_insertColumn example?
http://forum.easyxls.com/viewtopic.php?f=9&t=2226
Page 1 of 1

Author:  dalbright@rrsc.com [ Mon Aug 07, 2017 2:04 pm ]
Post subject:  easy_insertColumn example?

Can someone show me a C# example of how to properly use the easy_insertColumn command?

Author:  daniela [ Wed Aug 09, 2017 11:09 am ]
Post subject:  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);
}

Page 1 of 1 All times are UTC - 4 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/