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

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested answer

Import Excel data to custom Blob field using custom procedure

(4) ShareShare
ReportReport
Posted on by 259
Hello,
I want to import data from excel sheet into a blob field. Please help me with the code. I am attaching my code here, please suggest me what to modify.
 
    Local Procedure GetValueAtCellBlob(RowNo: Integer; ColNo: Integer): BigText
    var
        TempBlob: Codeunit "Temp Blob";
        InStream: InStream;
        OutStream: OutStream;
        CellValue: BigText;
        BlobText: Text;
    begin
        TempExcelBuffer.Reset();
        If TempExcelBuffer.Get(RowNo, ColNo) then begin
            TempExcelBuffer.CalcFields("Cell Value as Blob");
            if TempExcelBuffer."Cell Value as Blob".Length <> 0 then begin
                TempExcelBuffer.CalcFields("Cell Value as Blob");
                TempExcelBuffer."Cell Value as Blob".CreateInStream(InStream);
                InStream.ReadText(BlobText);
                CellValue.AddText(BlobText);
            end;
        end;
        exit(CellValue);
    end;
 
   
 Local Procedure ImportblobBasicData(var pR_itemrecord: Record "demo item")
    var
        localItemRecord: Record "demo item";
        demoitemID: code[50];
        TempBlob: Codeunit "Temp Blob";
        OutStream1: OutStream;
        demoitemText: bigText;
    begin
        TempExcelBuffer.Reset();
        if TempExcelBuffer.FindLast() then
            MaxRowNo := TempExcelBuffer."Row No.";
        for RowNo := 2 to MaxRowNo do begin
            localItemRecord.Reset();
            Evaluate(demoitemID, GetValueAtCell(RowNo, 1));
            localItemRecord.SetRange("demoitem ID", demoitemID);
            if localItemRecord.FindFirst() then begin
                // Get description from Excel
                demoitemText := GetValueAtCellBlob(RowNo, 2);
                if demoitemText.Length <> 0 then begin
                    ReplaceSpecialCharacterInBigText(demoitemText);
                    localItemRecord."demoitem Description Text".CreateOutStream(OutStream1);
                    OutStream1.Write(demoitemText);
                end;
                localItemRecord.Modify();
            end;
        end;
    end;
 
    Local Procedure ReplaceSpecialCharacterInBigText(TextToModify: BigText)
    var
        TempText: Text;
        OutStream: OutStream;
    begin
        Clear(TempText);
        TextToModify.GetSubText(TempText, 1);
        // Replace special characters
        TempText := TempText.Replace('(¹)', '(Ø)');
        TempText := TempText.Replace('ò', '•');
        TempText := TempText.Replace('â„¢', 'Ö');
        TempText := TempText.Replace('Æ', '’');
        Clear(TextToModify);
        TextToModify.AddText(TempText);
    end;
 
 
 
 
I have the same question (0)
  • Suggested answer
    YUN ZHU Profile Picture
    92,443 Super User 2025 Season 2 on at
    Import Excel data to custom Blob field using custom procedure
    Hi, you can refer to the following standard feature.
    Business Central 2024 wave 1 (BC24): Export, import multiline text with Configuration Packages (Use BLOB type fields in Configuration Packages)
     
    PS:
    Dynamics 365 Business Central: How to export Work Description (Blob) in Sales Documents to excel
    Dynamics 365 Business Central: How to use Excel Buffer to Import data
    Dynamics 365 Business Central: How to save a report as encoded text (Base64 String) via AL
     
    Thanks.
    ZHU

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
Rishabh Kanaskar Profile Picture

Rishabh Kanaskar 4,132

#2
Nimsara Jayathilaka. Profile Picture

Nimsara Jayathilaka. 3,615

#3
Sumit Singh Profile Picture

Sumit Singh 2,912

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans