2.2.4.46.83 Worksheet::SetSizeSetSize
Description
Set the number of columns and rows of worksheet
Syntax
BOOL SetSize( int nNumRows, int nNumCols, DWORD dwCntrl = 0 )
Parameters
- nNumRows
- [input] number of rows in worksheet, use <0 to keep current settings
- nNumCols
- [input] number of columns, use <0 to keep current settings
- dwCntrl
- [input] decide if existing data in worksheet should be cleared. If WSS_CLEAR_DATA, then all data in worksheet is reset to missing values and each column is reset to upper index = 0,
- if WSS_CLEAR_DATA not set(by default), then no action is taken on both the data and the upper index on each column, and newly added columns will be in default state.
- If WSS_CLEAR_DATA is set, you can further use WSS_FILL_ZERO or WSS_FILL_BLANK instead of the default of filling with missing values
Return
TRUE on success and FALSE on failure.
Examples
EX1
// the following code will reset the active worksheet with 3000 enumerated cols
void Worksheet_SetSize_Ex1()
{
Worksheet wks = Project.ActiveLayer();
if(wks)
{
wks.SetSize(-1,0); // delete existing columns
wks.SetSize(1000,3000); // make a worksheet with 3000 cols with 1000 rows each
}
}
EX2
// a function to clear a worksheet
// WARNING! Active worksheet data will be deleted
void Worksheet_SetSize_Ex2()
{
Worksheet wks = Project.ActiveLayer();
if(wks)
wks.SetSize(-1, -1, WSS_CLEAR_DATA);
}
Remark
If nNumCols is larger then the current number of columns in the worksheet, then new columns will be added using enumerated column names which is faster then calling AddCol.
Also, Origin does not support small number of rows in worksheet display, so setting a value of nNumRows smaller then the height of the display will be ignored.
See Also
Worksheet::AddCol, Worksheet::DeleteCol, Worksheet::SetBounds
Header to Include
origin.h
|