Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7659271
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T13:18:40+00:00 2026-05-31T13:18:40+00:00

I am working with the openxml sdk and have a table to write to

  • 0

I am working with the openxml sdk and have a table to write to a word doc. Once i have written my table, is there anyway to select all the columns for that table and delete one of them based on the text for that column? For example:

foreach (var column in table.columns)
{
    if (column.Text == "Hello")
    {
       table[column].delete();
    }
}

Is there a real world implementation of the above pseudo code?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T13:18:40+00:00Added an answer on May 31, 2026 at 1:18 pm

    Unfortunately, there is no concept of a “column” in a word processing table (DocumentFormat.OpenXml.WordProcessing.Table), only rows and cells. If you can assume the first row contains column names, and all rows contain the same number of cells, you can accomplish your task. One thing you have to be careful of (and one problem in your pseudocode above) is that you can’t delete things from the enumeration you’re currently iterating over. Here’s how I would accomplish this:

    var rows = table.Elements<TableRow>();
    var firstRowCells = rows.ElementAt(0).Elements<TableCell>();
    var cellNumbersToDelete = new List<int>();
    for( int i=0; i<firstRowCells.Count(); i++ )
      if( GetCellText( firstRowCells.ElementAt( i ) ) == "Hello" )
        cellNumbersToDelete.Add( i );
    foreach( var cellNumberToDelete in cellNumbersToDelete ) {
      foreach( var row in rows ) {
        cellToDelete = row.ElementAt( cellNumberToDelete );
        row.RemoveChild( cellToDelete );
      }
    }
    

    I don’t have time right now to test this solution, so it’ll probably require some tweaking, but it should give you a general idea about how to accomplish your task. The method GetCellText referenced above would look something like this:

    string GetCellText( TableCell cell ) {
      var p = cell.Elements<Paragraph>().First();
      var r = p.Elements<Run>().First();
      var t = r.Elements<Text>().First();
      return t.Text;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating a simple word doc, using the openXml SDK. It is working
I am trying to start working with Excel documents through the OpenXML SDK Spreadsheet
I am working with OpenXML manipulating the document. Do we need to have office
(I am working interactively with a WordprocessingDocument object in IronPython using the OpenXML SDK,
Working sample using one Table SELECT t.* FROM ( SELECT TITLE.name, (TITLE.value-TITLE.msp) AS Lower,
I have created a Word template that I am then processing via the OpenXML
I'm working with an OpenXML document, processing the main document part with some XSLT.
Working on a project at the moment and we have to implement soft deletion
Working on a website http://www.ArenaText.com written in asp.net with Microsoft AJAX control toolkit. iPad
Working example: http://alpha.jsfiddle.net/gTpWv/ Both of the methods work separately, but once regexp for smilies

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.