web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)

Update Excel Data using Dotnet Variable in NAV 2016

(0) ShareShare
ReportReport
Posted on by 7,885

Hello Experts,

Could you tell me how to do "Update Excel Data in excel sheet". Earlier i written code in NAV 2009 using Automation variable, But now i want to use dotnet variable. my earlier code is here...

2016_2D00_03_2D00_15_5F00_13_2D00_09_2D00_06.png

And i had tried using dotnet variable, my code is here...

2016_2D00_03_2D00_15_5F00_13_2D00_15_2D00_24-DotNet.png

In place of comments i have to write code.

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    HILBE Profile Picture
    300 on at

    1. Open Excel:

    Code:

    TmpExcelBuffer.OpenBook(FileName, SheetName);

    TmpExcelBuffer.ReadSheet;

    2.) Update Lines:

    Code:

    TmpExcelBuffer.GET(1,1);

    TmpExcelBuffer."Cell Value as Text" := 'Hello';

    3.) Update with new function in Excel buffer

    Create method UpdateSheet in Excel Buffer!

    Code:

    TmpExcelBuffer.UpdateBook(FileName,SheetName);

    TmpExcelBuffer.UpdateSheet(RowFilter, Spaltenfilter); //Which Row / Col TmpExcelBuffer.CloseBook;

    UpdateSheet - Parameter ->RowNoFilter Text30 / ColumnNoFilter Text30

    Code:

    LastUpdate := CURRENTDATETIME;

    ExcelBufferDialogMgt.Open(Text005);

    IF RowNoFilter_p > '' THEN

     SETFILTER("Row No.", RowNoFilter);

    IF ColumnNoFilter_p > '' THEN

     SETFILTER("Column No.", ColumnNoFilter);

    CRLF := 10;

    TotalRecNo := COUNT + InfoExcelBuf.COUNT;

    RecNo := 0;

    // commit is required because of the result boolean check of ExcelBufferDialogMgt.RUN

    COMMIT;

    IF FINDSET THEN

     REPEAT

       RecNo := RecNo + 1;

       IF NOT UpdateProgressDialog(ExcelBufferDialogMgt,LastUpdate,RecNo,TotalRecNo) THEN BEGIN

         QuitExcel;

         ERROR(Text035)

       END;

    //    IF Formula = '' THEN

         WriteCellValue(Rec)

    //    ELSE

    //      WriteCellFormula(Rec)

     UNTIL NEXT = 0;

    ExcelBufferDialogMgt.Close;

    ---

    Thats it!

  • Suggested answer
    Roberto Stefanetti Profile Picture
    12,998 on at

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.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics NAV (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans