开发者

iTextSharp: Need help to repeat some columns in the 1st row of the table after page break

I am creating a PDF document using iTextSharp. The document is a bunch of tables. Some of the tables span over a few pages.

First column is a date. If several rows of the table has the same date in 1st column, only I output date only in the first row, the following rows have a blank column - until the date changes.

I do it by storing last column value in a variable and comparing it before adding a cell in the new row.

But if a table doesn't fit in one page I want to repeat the date column on the first row after the page break, so the user doesn't have to return to the previous page to see the date.

My table has a header and it repeats on new pages fine (I am setting PdfPTable.HeaderRows).

I tried to clear my variable that store last printed date in onStartPage and onEndPage but it didn't help.

Basically I want something like this:

(Beginning of the table)


=======================================================
  Date           Something related to the date        
==开发者_JS百科===================================================== 
  01/01/2011     Something happened on January 1
                 Something else happened on this day
  01/05/2011     Here is another day
  01/07/2011     New day
                 Still 01/07/2011
                 Still there

(After page break - the table continues and the date repeats in 1st row)

=======================================================
  Date           Something related to the date        
======================================================= 
  01/07/2011     It is still January 7th but the date 
                 column repeats as this is a new page
                 And still the 7th
  01/15/2011     New day now
  01/17/2011     And another day

Any help will be appreciated.

Thanks


Consider grouping your list first by date before adding it to PdfTable.This can be easily achieve by using LINQ. After grouping, iterate to each group and add the date group value in the first column and then iterate through each member of the group and add them all (values related to the date) up in the second column.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜