Skip to main content

Notifications

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

Remove Line item datas

Posted on by 44
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.
 
 
Categories:
  • 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.
  • Suggested answer
    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 

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Complete!

🔔 Be sure to subscribe to the new forums you are interested in to stay up to date! 🔔

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,134 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 229,928 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans