PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Thu Mar 28, 2024 11:12 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Sat May 30, 2020 1:57 am 
Offline

Joined: Mon May 18, 2020 6:44 am
Posts: 11
I am looking at the samples of migradoc invoice example but I am still not understanding it. I could possibly have more than one row of invoices, each with a cost. I then want the cost of all the invoice rows to be displayed into a table cell that says "total". For now I have only one row of data with a cost of "60.00." I looked into using GetValue() but not sure how to use it in my case.

So I basically am figuring i need to somehow create a variable to where I am storing the selected cells value and then somehow be able to add it and other subsequent costs to the totals cell.


Code:
//define a row of data in the table
            foreach (TicketView1 ticket in SampleTickets)
            {
                row = table.AddRow();

                cell = row.Cells[0];
                cell.AddParagraph(ticket.customer_name);

                cell = row.Cells[1];
                cell.AddParagraph(ticket.date_created.ToString("MM/dd/yyyy"));

                cell = row.Cells[2];
                cell.AddParagraph(ticket.description);

                cell = row.Cells[3];
                cell.AddParagraph(ticket.due_date.ToString("MM/dd/yyyy"));

                cell = row.Cells[4];
                cell.AddParagraph(ticket.billable_hrs.ToString());
            }

            cell = row.Cells[5];
            cell.AddParagraph("$60.00");

           

            //add invisible row as a space line to the table
            row = table.AddRow();
            row.Borders.Visible = false;

            //add the subtotal row
            row = table.AddRow();
            row.Cells[0].Borders.Visible = false;
            row.Cells[0].AddParagraph("Sub Total:");
            row.Cells[0].Format.Font.Bold = true;
            row.Cells[0].Format.Alignment = ParagraphAlignment.Right;
            row.Cells[0].MergeRight = 4;
            cell = row.Cells[5];
           


            //add tax row
            row = table.AddRow();
            row.Cells[0].Borders.Visible = false;
            row.Cells[0].AddParagraph("TAX:");
            row.Cells[0].Format.Font.Bold = true;
            row.Cells[0].Format.Alignment = ParagraphAlignment.Right;
            row.Cells[0].MergeRight = 4;

            //add total
            row = table.AddRow();
            row.Cells[0].Borders.Visible = false;
            row.Cells[0].AddParagraph("TOTAL:");
            row.Cells[0].Format.Font.Bold = true;
            row.Cells[0].Format.Alignment = ParagraphAlignment.Right;
            row.Cells[0].MergeRight = 4;
         


        }


Top
 Profile  
Reply with quote  
PostPosted: Mon Jun 01, 2020 4:42 am 
Offline

Joined: Mon May 18, 2020 6:44 am
Posts: 11
I was able to figure it out with some help.

I created a count variable called sum just before my forEach loop. Inside my forEach loop where i created a row and paragraph for the costs column, underneath I put the sum variable plus 60 since that's my dummy data for now.

Later, where I created the totals row and in the totals cell, i put :

Code:
row.Cells[5].AddParagraph(sum.ToString("$0.00"));


It seems to put my data inside that specific cell which is what I needed.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 131 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group