Announcements
No record found.
Hello,
I use SQL language to get Data in Excel.
I think that is passable show in AX for user to use?
Where is quickly way to do this??
Thanks in advance.
*This post is locked for comments
Yes. You can directly insert the sql query in AX table without copying it to Excel. Then you can display the table through a form.If you can give more details, then I might be able to suggest you a solution.
Hi ATMA-Jen,
Can you explain more?with example.Plz
Also go through my answer, I wrote earlier:
community.dynamics.com/.../303452
You can query the data from SQL Server in X++ and disply it.
- Reference: docs.microsoft.com/.../how-to-connect-to-an-external-database-from-x-code
Or you can make use of EP site(actually SharePoint). Its external list feature can show the data from extenal sql database without any code required, just some comfiguration steps.
- Reference: support.office.com/.../create-an-external-list-6e2d601d-b02f-41e7-ba87-e70297ec6665
static void ImportExcel(Args _args) { SysExcelApplication application; SysExcelWorkbooks workbooks; SysExcelWorkbook workbook; SysExcelWorksheets worksheets; SysExcelWorksheet worksheet; SysExcelCells cells; FileName filename; str yourParameter; str st1, st2; int row = 0 ; SysLabelEdit SysLabelEdit = new SysLabelEdit(); application = SysExcelApplication::construct(); workbooks = application.workbooks(); //specify the file path that you want to read filename = "D:\\importtest.xlsx"; 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++; yourParameter= cells.item(row, 1).value().bStr(); } while (row != CountOfExcelRow); application.quit(); }
Hi ATMA-Jen,For get data from excel and insert in table in sql server(for example TblTest):
static void ImportExcel(Args _args) { SysExcelApplication application; SysExcelWorkbooks workbooks; SysExcelWorkbook workbook; SysExcelWorksheets worksheets; SysExcelWorksheet worksheet; SysExcelCells cells; FileName filename; str yourParameter; str st1, st2; int row = 0 ; TblTest tblTest1; SysLabelEdit SysLabelEdit = new SysLabelEdit(); application = SysExcelApplication::construct(); workbooks = application.workbooks(); //specify the file path that you want to read filename = "D:\\importtest.xlsx"; 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++; yourParameter= cells.item(row, 1).value().bStr();
tblTest1.field1 = yourParameter;
tblTest1.insert();
} while (row != CountOfExcelRow); application.quit(); }
Under review
Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.
Congratulations to our 2026 Super Stars!
We are thrilled to have these Champions in our Community!
These are the community rock stars!
Stay up to date on forum activity by subscribing.
CP04-islander 39
Michel ROY 14
imran ul haq 8