Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SheetName := ExcelBuffer.ItemBoxQuantitySheet(InStream);
- if SheetName = '' then
- exit;
- ExcelBuffer.Reset();
- ExcelBuffer.DeleteAll();
- ExcelBuffer.OpenBookStream(InStream, SheetName);
- ExcelBuffer.ReadSheet();
- // 3. Find the last row to determine the loop length
- if ExcelBuffer.FindLast() then
- MaxRow := ExcelBuffer."Row No.";
- // 4. Loop through rows (Starting at 2 to skip header row)
- for RowNo := 2 to MaxRow do begin
- ItemNo := GetValueAtCell(RowNo, 1);
- BoxQtyTxt := GetValueAtCell(RowNo, 2);
- // Convert text to decimal safely
- if not Evaluate(BoxQty, BoxQtyTxt) then
- BoxQty := 0;
- // 5. Create the Item Card Comment
- if ItemNo <> '' then
- CreateItemComment(ItemNo, BoxQty);
- end;
- Message('Item Comments imported successfully!');
- end;
- local procedure GetValueAtCell(RowNo: Integer; ColNo: Integer): Text
- begin
- if ExcelBuffer.Get(RowNo, ColNo) then
- exit(ExcelBuffer."Cell Value as Text");
- exit('');
- end;
- local procedure CreateItemComment(ItemNo: Code[20]; BoxQty: Decimal)
- var
- CommentLine: Record "Comment Line";
- Item: Record Item;
- NextLineNo: Integer;
- begin
- // Step A: Check if the item actually exists before adding a comment
- if not Item.Get(ItemNo) then
- exit;
Advertisement
Add Comment
Please, Sign In to add comment