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

Announcements

News and Announcements icon
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 301
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
    101,787 Super User 2026 Season 1 on at
    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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,497 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,778 Super User 2026 Season 1

#3
AndrewThomas81 Profile Picture

AndrewThomas81 1,507

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans