Import Excel Date to Ax

Hi

Import excel Data to Ax with X++ code

Any body help me out…

Thanks in advanc…

Table.Date = excelWorksheet.cells().item(TotalRow,6).value().date();

Hi,

try this it may help you…

static void ImportDatafromExcel(Args _args)
{
SysExcelApplication application;
SysExcelWorkbooks workbooks;
SysExcelWorkbook workbook;
SysExcelWorksheets worksheets;
SysExcelWorksheet worksheet;
SysExcelCells cells;
COMVariantType type;
int row;

CustAccount custAccount;
Name name;
FileName filename;
CustTable CustTable;
;
filename = “E:\CustTable.xlsx”;
application = SysExcelApplication::construct();
workbooks = application.workbooks();
workbooks.open(fileName,0,true);

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();
do
{
row++;
custAccount = cells.item(row, 1).value().bStr();
name = cells.item(row, 2).value().bStr();
type = cells.item(row+1, 1).value().variantType();

CustTable.clear();
if(!custTable::find(custAccount))
{
CustTable.AccountNum = custAccount;
CustTable.Name = name;
CustTable.insert();
}
}

while (type != COMVariantType::VT_EMPTY);
application.quit();
}

Naresh.

Hi,

try this it may help you…

static void ImportDatafromExcel(Args _args)
{
SysExcelApplication application;
SysExcelWorkbooks workbooks;
SysExcelWorkbook workbook;
SysExcelWorksheets worksheets;
SysExcelWorksheet worksheet;
SysExcelCells cells;
COMVariantType type;
int row;

CustAccount custAccount;
Name name;
FileName filename;
CustTable CustTable;
;
filename = “E:\CustTable.xlsx”;
application = SysExcelApplication::construct();
workbooks = application.workbooks();
workbooks.open(fileName,0,true);

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();
do
{
row++;
custAccount = cells.item(row, 1).value().bStr();
name = cells.item(row, 2).value().bStr();
type = cells.item(row+1, 1).value().variantType();

CustTable.clear();
if(!custTable::find(custAccount))
{
CustTable.AccountNum = custAccount;
CustTable.Name = name;
CustTable.insert();
}
}

while (type != COMVariantType::VT_EMPTY);
application.quit();
}

Naresh.

Hi,

try this it may help you…

static void ImportDatafromExcel(Args _args)
{
SysExcelApplication application;
SysExcelWorkbooks workbooks;
SysExcelWorkbook workbook;
SysExcelWorksheets worksheets;
SysExcelWorksheet worksheet;
SysExcelCells cells;
COMVariantType type;
int row;

CustAccount custAccount;
Name name;
FileName filename;
CustTable CustTable;
;
filename = “E:\CustTable.xlsx”;
application = SysExcelApplication::construct();
workbooks = application.workbooks();
workbooks.open(fileName,0,true);

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();
do
{
row++;
custAccount = cells.item(row, 1).value().bStr();
name = cells.item(row, 2).value().bStr();
type = cells.item(row+1, 1).value().variantType();

CustTable.clear();
if(!custTable::find(custAccount))
{
CustTable.AccountNum = custAccount;
CustTable.Name = name;
CustTable.insert();
}
}

while (type != COMVariantType::VT_EMPTY);
application.quit();
}

Naresh.

For Ex:

in Ax I have Table is Table_Test

Fields : No Name valid

100 Tensi Yes

200 betsn No

In this way I can store the values in Table

In excel I have values. with 3 fields .

I want to import the excel values to Table the record which ever have the valid is Yes only I have to import … for that what I have code. complete code…

Thanks in advance.

No offence man, but I wonder if Google search engine has been disabled for India… because this is such a general thing in AX for which you could easily find your answer in just few minutes by a little research…

Take a look at this:

http://axforum.info/forums/showthread.php?t=31444&langid=1

how to add time (format data ) from excel to ax?

i solved my problem