[ ax2012 ] import excel file

application = SysExcelApplication::construct();
workBooks = application.workbooks();
workBooks.open(filename,0,true);

workSheets = workBooks.item(1).worksheets();

Count number of worksheets

workSheets.count()

Get the ith Sheet name 

workSheets.itemFromNum(i).name()

Get Sheet

workSheet = workSheets.itemFromName(input);

Get Last Row

range = workSheet.cells().range(#ExcelTotalRange);
range.row(); // number of rows

 Get Cell value

COMVariant cells.item(rowIdx,colIdx).value()

Get VariantType

COMVariantType comVariant.variantType()

COMVariantType::VT_BSTR = string

COMVariantType::VT_R4 = float

COMVariantType::VT_R8 = double

COMVariantType::VT_DECIMAL = decimal

COMVariantType::VT_DATE = date

COMVariantType::VT_EMPTY = None

Error

application.displayAlerts(false);

Release Resource

application.quit();
application = null;
workbooks.close();

See another excel import example from krishhdax

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s