Reply to topic  [ 2 posts ] 
easy_insertColumn example? 
Author Message

Joined: Mon Aug 07, 2017 1:29 pm
Posts: 1
Reply with quote
Post easy_insertColumn example?
Can someone show me a C# example of how to properly use the easy_insertColumn command?


Mon Aug 07, 2017 2:04 pm
Profile

Joined: Fri Feb 03, 2006 12:23 pm
Posts: 189
Location: Brasov, Romania
Reply with quote
Post 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);
}

_________________
EasyXLS Team
.NET and Java library to read and write Excel files
Facebook Twitter Reddit LinkedIn


Wed Aug 09, 2017 11:09 am
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 2 posts ] 

Who is online

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

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.