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

Remove Line item datas

(0) ShareShare
ReportReport
Posted on by 85
Hi,
 
////
 
 
 
Please someone tell me. For this report Standard Sales - Invoice we need to remove line items in the Word report.  
 
please provide the sample/reference code in Business Central AL Technologies.
 
 
I have the same question (0)
  • Suggested answer
    Community member Profile Picture
    4 on at
    Remove Line item datas
    Hello , 
    To remove line items from a Word report programmatically, you can use the Microsoft Office Open XML SDK.   
    sample code snippet in C# that demonstrates how to remove line items from a Word document: 
    write this code : 
     
    using DocumentFormat.OpenXml;
    using DocumentFormat.OpenXml.Packaging;
    using DocumentFormat.OpenXml.Wordprocessing;
    public void RemoveLineItems(string filePath)
    {
        using (WordprocessingDocument document = WordprocessingDocument.Open(filePath, true))
        {
            // Get the main document part
            MainDocumentPart mainPart = document.MainDocumentPart;
            // Get all paragraphs in the document
            var paragraphs = mainPart.Document.Body.Descendants<Paragraph>();
            foreach (var paragraph in paragraphs)
            {
                // Check if the paragraph contains line item content
                if (paragraph.InnerText.Contains("Line Item"))
                {
                    // Remove the paragraph
                    paragraph.Remove();
                }
            }
            // Save the changes
            mainPart.Document.Save();
        }
    }
     
    if any issue to contant me , i will help you 
  • Community member Profile Picture
    4 on at
    Remove Line item datas
    Sorry 
     i have more add this you can see this 
           In the above code, the RemoveLineItems method takes the file path of the Word document as input and opens it Pay My Doctor using the Open XML SDK. It iterates through each paragraph in the document and checks if it contains the text "Line Item". If it does, the paragraph is removed.
         Please note that this is a basic example, and you may need to modify the code based on the structure and formatting of your specific Word document. Additionally, make sure to add the necessary references to the Open XML SDK in your project.

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…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,921

#2
YUN ZHU Profile Picture

YUN ZHU 2,012 Super User 2025 Season 2

#3
Jainam M. Kothari Profile Picture

Jainam M. Kothari 1,999 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans