Skip to main content

Notifications

Announcements

No record found.

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

Remove Line item datas

(0) ShareShare
ReportReport
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.
 
 
  • 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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,445 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans