Показать сообщение отдельно
Старый 28.11.2012, 19:11   #1  
Blog bot is offline
Blog bot
Участник
 
25,643 / 848 (80) +++++++
Регистрация: 28.10.2006
Malaysia: Reading an Excel file
Источник: http://axmas.blogspot.com/2012/11/re...xcel-file.html
==============


1. In the AOT, create a new job named ReadExcelFile with the following code
(replace the file name with your own):

static void ReadExcelFile (Args _args)
{
SysExcelApplication excel;
SysExcelWorkbooks workbooks;
SysExcelWorkbook workbook;
SysExcelWorksheets worksheets;
SysExcelWorksheet worksheet;

SysExcelCells cells;
COMVariantType type;
int row;
CustAccount account;
CustName name;
#define.filename(@'C:\temp\customers.xlsx')
excel = SysExcelApplication::construct();
workbooks = excel.workbooks();
try
{
workbooks.open(#filename);
}
catch (Exception::Error)
{
throw error("File cannot be opened");
}
workbook = workbooks.item(1);
worksheets = workbook.worksheets();
worksheet = worksheets.itemFromNum(1);
cells = worksheet.cells();
type = cells.item(row+1, 1).value().variantType();
while (type != COMVariantType::VT_EMPTY)
{
row++;
account = cells.item(row, 1).value().bStr();
name = cells.item(row, 2).value().bStr();
info(strFmt('%1 - %2', account, name));
type = cells.item(row+1, 1).value().variantType();
}
excel.quit();
}


2. Run the job to display the contents of the file in the Infolog, as shown in the
following screenshot:







Источник: http://axmas.blogspot.com/2012/11/re...xcel-file.html
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.