PDFsharp & MigraDoc Foundation
http://forum.pdfsharp.net/

Compare Table Cell with String
http://forum.pdfsharp.net/viewtopic.php?f=2&t=3648
Page 1 of 1

Author:  Hadda [ Thu Aug 24, 2017 2:46 pm ]
Post subject:  Compare Table Cell with String

Hi,

I'm new at MigraDoc and have the following Problem.

I have a Migradoc
Code:
var table
for my PDF document. There are multiple Rows with a person ID, name, firstname and so on. Now I would like to compare the table id with a string, like:

Code:
if (table.Rows[i][10].ToString() == Person.ID && table.Rows[i][10].ToString() != "")
{
    //do something
}

Unfortunately, he does not go into the query because I think
Code:
table.Rows[i][10].ToString()
is not the correct call. Is there a way to call the value of the cell?

I'm using MigraDoc with WPFBuild in Version 1.32

Author:  Thomas Hoevel [ Thu Aug 24, 2017 3:52 pm ]
Post subject:  Re: Compare Table Cell with String

Hi!
Hadda wrote:
Is there a way to call the value of the cell?
Yes, but there is no simple way. A cell can contain many document elements. In the most simple case you have a paragraph with a text element.

Your code fills the cell so your code should know what's in it. Maybe keep an array where you can lookup the ID for row 5.

Simple workaround: assign the text you put into that cell to the "Tag" member of the cell and use that for comparison. No extra array needed.

Author:  Hadda [ Fri Aug 25, 2017 1:12 pm ]
Post subject:  Re: Compare Table Cell with String

Thomas Hoevel wrote:
Hi!
Hadda wrote:
Is there a way to call the value of the cell?
Yes, but there is no simple way. A cell can contain many document elements. In the most simple case you have a paragraph with a text element.

Your code fills the cell so your code should know what's in it. Maybe keep an array where you can lookup the ID for row 5.

Simple workaround: assign the text you put into that cell to the "Tag" member of the cell and use that for comparison. No extra array needed.


Thank you. That worked for me :)

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/