table import

Can I import an excel file by creating a job?

Hi,

I am assuming that you want to automate the process? If so, You can create a report or codeunit to run this process. Dataports won’t work for you.

Good luck, John

Excuse my ignorance but how do I that?

I just realized that creating a report won’t work with end user because they won’t have an access to AX. The excel file that I need to import changes every week. What should I do to so it’ll enable the end user to import files from excel without going importing it to the database?

Did you mention AX? Or is this a NAV import?

yep it’s in AX.

OK. I know nothing about AX. Sorry about that

Hi,

It will be easier to import if the file is in CSV format. If you do a search, you will find many very useful posts here.

both files are in csv format .The problem is data of the those files changes every week. The flaw of the program is that end users don’t have access to ax. So my question now is, how can I make a form that will inable the end users import the files w/out using the ax import system?

Hello James,

Yes User can import data without using Ax, you need to create a batch class for this type of importing and also you have to specify the path of this files in batch class. I have the job for importing the CSV files in the system. If you want that job , i can send that job on your mail.

Regards

Varun Garg

static void ExceltoAx(Args _args)

{

SysExcelApplication application;

SysExcelWorkbooks workbooks;

SysExcelWorkbook workbook;

SysExcelWorksheets worksheets;

SysExcelWorksheet worksheet;

SysExcelCells cells;

SysOperationProgress progress;

COMVariantType type; // excel

Dialog dialog;

DialogField df1,df4,df3,df2,df5; //dialog

Filename filename;

int firstrow, secondrow,row2,i=0;

ActionDate ad;

DlvTermId itemid;

DlvModeId name;

Exceltest exceltest; // table to import into

#AviFiles

// #AviTransfer

#Excel

#file

;

application = SysExcelApplication::construct();

workbooks = application.workbooks();

dialog = new Dialog(“Nishant’s Dialog Form”);

dialog.filenameLookupFilter(["@SYS28576",#AllFilesName+#XLS+’;’+#XLSM+’;’+#XLSX]);

dialog.filenameLookupTitle(“Upload from EXCEL”);

dialog.addGroup(“Spreadsheets”);

df1 = dialog.addField(typeid(Filenameopen), “File Name”);

df2 = dialog.addField(typeid(StartRow),“Start Row”); //from row

df3 = dialog.addField(typeid(EndRow),“End Row”); //end Row

dialog.addGroup(“Process Mode”);

df4 = dialog.addField(typeid(errorLog),“Error log”);

dialog.addGroup(“Error log”);

df5 = dialog.addField(typeid(validateexcel),“Validation”);

dialog.run();

if (dialog.run())

{

filename = (df1.value());

}

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();

//start row and end row functionality

firstrow= df2.value();

secondrow=df3.value();

row2=secondrow-firstrow;

info(strfmt(’%1 - %2’,row2));

do

{

firstrow++;

itemId = cells.item(firstrow, 1).value().bStr();

name = cells.item(firstrow, 2).value().bStr();

info(strfmt(’%1 - %2’, itemId, name));

//to insert data from xcel to ax

//ttsbegin;

//exceltest.Delivery= name;

//exceltest.Description=itemid;

//exceltest.insert();

//ttscommit;

//update multiple data from excel.

Update_recordset exceltest

setting delivery=itemId

where exceltest.Description==name;

type = cells.item(firstrow+1, 1).value().variantType();

}

while (type!=COMVariantType::VT_EMPTY && row2!=i);

application.quit();

}

Varun Garg, Yes please send it to my mail. thanks for your help. I Really appreciate it…