How to Import Records from Excel Using X++ Code in D365FO

  How to Import Records from Excel Using X++ Code in D365FO   Include the below namespace in X++ code it will requires to import Excel. Using System.IO; Using OfficeOpenXml; Using OfficeOpenXml.ExcelPackage; Using OfficeOpenXml.ExcelRange;   In addition to the basic reference, include (Directory and DirectoryUpgrade Packages) X++ Code: Using System.IO; Using OfficeOpenXml; Using OfficeOpenXml.ExcelPackage; Using OfficeOpenXml.ExcelRange; class ReadExcel {   public static void main(Args _args)    {     Int id;     Str Name;      System.IO.Stream stream;       ExcelSpreadsheetName sheet;              FileUploadBuild fileUpload,fileUploadBuild;       DialogGroup dialogUploadGroup;       FormBuildControl formBuildControl;   ...

Writing data to TSV file in D365FO using X++


Writing data to TSV file in D365 FO using X++

class WriteDataToTSVFile

{        

      public static void main(Args _args)

      {  

   TextIo           file;

   str              fileName;

   FileIOPermission IOPermission;

   container        cont;

   #File

   ;

   try

   {

   fileName = "C:\\TSVDataFile.txt";

           //If you want to write after deleting previous data, use #IO_WRITE instead of #IO_APPEND

   IOPermission = new FileIOPermission(fileName, #IO_APPEND);

   IOPermission.assert();

   file = new TextIo(filename, #IO_APPEND);

   file.outRecordDelimiter(#delimiterCRLF);

   file.outFieldDelimiter("\t");//It will create one tab separated row/line in the text file.

   cont = connull();

   cont = conins(cont, 1, "FNAME");

   cont = conins(cont, 2, "MNAME");

   cont = conins(cont, 3, "LANME");               

   file.writeExp(cont);

            

   }

   catch(Exception::Error)

   {

            error("ERROR");

   }

   CodeAccessPermission::revertAssert();

}

}


Comments

Popular posts from this blog

D365 FO: REFRESH CALLER FORM DATA SOURCE FROM A CLASS X++

Passing Args from one Form to another Form in dynamics AX

CREATE AND POSTING PURCHASE ORDER THROUGH X++ DYNAMICS AX