Excel Package



  1. Excel Package In Computer
  2. Excel Packaging Equipment
  3. Open Excelpackage

Hi Friends,

Been long. Hope all is well. Work kept me busy.

Below is the code snippet which will be handy to read the data from excel using code in D365/ax 7

Excel package in computer

Please note that, in D365 SysExcel* classes have been deprecated.

An archive of the CodePlex open source hosting site. ORAEXCEL (Oracle Excel) is a PL/SQL package for Oracle® database that produces Excel XLSX documents. ORAEXCEL enables developers to create Excel reports or export data from an Oracle® database to Excel files using a simple PL/SQL Excel API.

Under your references node in solution explorer, add Microsoft.Office.InterOp.Excel reference

Use OfficeOpenXML namespace to achieve this. Improvise the below snippet based on your need.

using System.IO;

using OfficeOpenXml;

using OfficeOpenXml.ExcelPackage;

using OfficeOpenXml.ExcelRange;

classSRReadFromExcel_D365

{

publicstaticvoid main(Args _args)

{

System.IO.Stream stream;

ExcelSpreadsheetName sheeet;

FileUploadBuild fileUpload;

DialogGroup dlgUploadGroup;

FileUploadBuild fileUploadBuild;

FormBuildControl formBuildControl;

Dialog dialog = newDialog(“Import the data from Excel”);

dlgUploadGroup = dialog.addGroup(“@SYS54759”);

formBuildControl = dialog.formBuildDesign().control(dlgUploadGroup.name());

fileUploadBuild = formBuildControl.addControlEx(classstr(FileUpload), ‘Upload’);

fileUploadBuild.style(FileUploadStyle::MinimalWithFilename);

fileUploadBuild.fileTypesAccepted(‘.xlsx’);

if (dialog.run() && dialog.closedOk())

{

FileUpload fileUploadControl = dialog.formRun().control(dialog.formRun().controlId(‘Upload’));

FileUploadTemporaryStorageResult fileUploadResult = fileUploadControl.getFileUploadResult();

if (fileUploadResult != null && fileUploadResult.getUploadStatus())

{

stream = fileUploadResult.openResult();

using (ExcelPackage Package = new ExcelPackage(stream))

{

int rowCount, i;

Package.Load(stream);

ExcelWorksheet worksheet = package.get_Workbook().get_Worksheets().get_Item(1);

OfficeOpenXml.ExcelRange range = worksheet.Cells;

rowCount = worksheet.Dimension.End.Row – worksheet.Dimension.Start.Row + 1;

for (i = 2; i<= rowCount; i++)

{

info(range.get_Item(i, 1).value);

info(range.get_Item(i, 2).value);

}

Excel Package In Computer

}

}

else

Excel Packaging Equipment

{

Open Excelpackage

error(“Error here”);

}

}

}

}

Happy Dax6ng