Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Fri Aug 02, 2024 2:48 pm

I have a PdfGrid that looks something like this:

Code: Select all
-----------------------------------
|                   |                     | Col3, Row1 |
| Col1, Row1 | Col2, Row 1 |-----------
|                   |                     | Col3, Row2 |
-----------------------------------

Col1, Row1 and Col2, Row1 have RowSpan=2 and ColSpan=2
Col3, Row1 has RowSpan=1 and ColSpan=1

How do I get data into Col3, Row2?

tim8w123
 
Posts: 13
Joined: Wed Feb 22, 2023 3:55 pm

Mon Aug 05, 2024 7:29 am

Hi,

Thank you for inquiry.
To place data into Col3, Row2, you can use the code "row2.cells [4].Value = "data". If there is any misunderstanding, please provide us with your complete code for further investigation.

Sincerely,
Amin
E-iceblue support team
User avatar

Amin.Gan
 
Posts: 164
Joined: Mon Jul 15, 2024 5:40 am

Mon Aug 05, 2024 2:11 pm

Still can't get it to work. Here is my code and an update photo:

Code: Select all
                    // Row 1 - Daily Shifts - Days
                    pdfGridRow = grid.Rows.Add();
                    pdfGridRow.Height = 20f;
                    cell = pdfGridRow.Cells[0];
                    cell.ColumnSpan = 4;
                    cell.Value = "Daily Shifts";
                    cell.StringFormat = centerCenterAlignment;
                    cell.Style.Borders = borders;
                    cell.Style.Font = font10Bold;
                    cell.Style.TextBrush = brushBlack;

                    cell = pdfGridRow.Cells[4];
                    cell.ColumnSpan = 2;
                    cell.Value = "Mon.";
                    cell.StringFormat = centerCenterAlignment;
                    cell.Style.Borders = borders;
                    cell.Style.Font = font10Bold;
                    cell.Style.TextBrush = brushBlack;

                    cell = pdfGridRow.Cells[6];
                    cell.ColumnSpan = 2;
                    cell.Value = "Tues.";
                    cell.StringFormat = centerCenterAlignment;
                    cell.Style.Borders = borders;
                    cell.Style.Font = font10Bold;
                    cell.Style.TextBrush = brushBlack;

                    cell = pdfGridRow.Cells[8];
                    cell.ColumnSpan = 2;
                    cell.Value = "Wed.";
                    cell.StringFormat = centerCenterAlignment;
                    cell.Style.Borders = borders;
                    cell.Style.Font = font10Bold;
                    cell.Style.TextBrush = brushBlack;

                    cell = pdfGridRow.Cells[10];
                    cell.ColumnSpan = 2;
                    cell.Value = "Thurs.";
                    cell.StringFormat = centerCenterAlignment;
                    cell.Style.Borders = borders;
                    cell.Style.Font = font10Bold;
                    cell.Style.TextBrush = brushBlack;

                    cell = pdfGridRow.Cells[12];
                    cell.ColumnSpan = 2;
                    cell.Value = "Fri.";
                    cell.StringFormat = centerCenterAlignment;
                    cell.Style.Borders = borders;
                    cell.Style.Font = font10Bold;
                    cell.Style.TextBrush = brushBlack;

                    cell = pdfGridRow.Cells[14];
                    cell.ColumnSpan = 2;
                    cell.Value = "Sat.";
                    cell.StringFormat = centerCenterAlignment;
                    cell.Style.Borders = borders;
                    cell.Style.Font = font10Bold;
                    cell.Style.TextBrush = brushBlack;

                    cell = pdfGridRow.Cells[16];
                    cell.ColumnSpan = 2;
                    cell.Value = "Sun.";
                    cell.StringFormat = centerCenterAlignment;
                    cell.Style.Borders = borders;
                    cell.Style.Font = font10Bold;
                    cell.Style.TextBrush = brushBlack;

                    // Row 2 - Inspection Method - 1st/2nd Shifts
                    pdfGridRow = grid.Rows.Add();
                    pdfGridRow.Height = 20f;
                    cell = pdfGridRow.Cells[0];
                    cell.ColumnSpan = 4;
                    cell.Value = "Inspection Method";
                    cell.StringFormat = centerCenterAlignment;
                    cell.Style.Borders = borders;
                    cell.Style.Font = font10Bold;
                    cell.Style.TextBrush = brushBlack;

                    cell = pdfGridRow.Cells[4];
                    cell.ColumnSpan = 1;
                    cell.Value = "1st";
                    cell.StringFormat = centerCenterAlignment;
                    cell.Style.Borders = borders;
                    cell.Style.Font = font10Bold;
                    cell.Style.TextBrush = brushBlack;

                    cell = pdfGridRow.Cells[5];
                    cell.ColumnSpan = 1;
                    cell.Value = "2nd";
                    cell.StringFormat = centerCenterAlignment;
                    cell.Style.Borders = borders;
                    cell.Style.Font = font10Bold;
                    cell.Style.TextBrush = brushBlack;

                    cell = pdfGridRow.Cells[6];
                    cell.ColumnSpan = 1;
                    cell.Value = "1st";
                    cell.StringFormat = centerCenterAlignment;
                    cell.Style.Borders = borders;
                    cell.Style.Font = font10Bold;
                    cell.Style.TextBrush = brushBlack;

                    cell = pdfGridRow.Cells[7];
                    cell.ColumnSpan = 1;
                    cell.Value = "2nd";
                    cell.StringFormat = centerCenterAlignment;
                    cell.Style.Borders = borders;
                    cell.Style.Font = font10Bold;
                    cell.Style.TextBrush = brushBlack;

                    cell = pdfGridRow.Cells[8];
                    cell.ColumnSpan = 1;
                    cell.Value = "1st";
                    cell.StringFormat = centerCenterAlignment;
                    cell.Style.Borders = borders;
                    cell.Style.Font = font10Bold;
                    cell.Style.TextBrush = brushBlack;

                    cell = pdfGridRow.Cells[9];
                    cell.ColumnSpan = 1;
                    cell.Value = "2nd";
                    cell.StringFormat = centerCenterAlignment;
                    cell.Style.Borders = borders;
                    cell.Style.Font = font10Bold;
                    cell.Style.TextBrush = brushBlack;

                    cell = pdfGridRow.Cells[10];
                    cell.ColumnSpan = 1;
                    cell.Value = "1st";
                    cell.StringFormat = centerCenterAlignment;
                    cell.Style.Borders = borders;
                    cell.Style.Font = font10Bold;
                    cell.Style.TextBrush = brushBlack;

                    cell = pdfGridRow.Cells[11];
                    cell.ColumnSpan = 1;
                    cell.Value = "2nd";
                    cell.StringFormat = centerCenterAlignment;
                    cell.Style.Borders = borders;
                    cell.Style.Font = font10Bold;
                    cell.Style.TextBrush = brushBlack;

                    cell = pdfGridRow.Cells[12];
                    cell.ColumnSpan = 1;
                    cell.Value = "1st";
                    cell.StringFormat = centerCenterAlignment;
                    cell.Style.Borders = borders;
                    cell.Style.Font = font10Bold;
                    cell.Style.TextBrush = brushBlack;

                    cell = pdfGridRow.Cells[13];
                    cell.ColumnSpan = 1;
                    cell.Value = "2nd";
                    cell.StringFormat = centerCenterAlignment;
                    cell.Style.Borders = borders;
                    cell.Style.Font = font10Bold;
                    cell.Style.TextBrush = brushBlack;

                    cell = pdfGridRow.Cells[14];
                    cell.ColumnSpan = 1;
                    cell.Value = "1st";
                    cell.StringFormat = centerCenterAlignment;
                    cell.Style.Borders = borders;
                    cell.Style.Font = font10Bold;
                    cell.Style.TextBrush = brushBlack;

                    cell = pdfGridRow.Cells[15];
                    cell.ColumnSpan = 1;
                    cell.Value = "2nd";
                    cell.StringFormat = centerCenterAlignment;
                    cell.Style.Borders = borders;
                    cell.Style.Font = font10Bold;
                    cell.Style.TextBrush = brushBlack;

                    cell = pdfGridRow.Cells[16];
                    cell.ColumnSpan = 1;
                    cell.Value = "1st";
                    cell.StringFormat = centerCenterAlignment;
                    cell.Style.Borders = borders;
                    cell.Style.Font = font10Bold;
                    cell.Style.TextBrush = brushBlack;

                    cell = pdfGridRow.Cells[17];
                    cell.ColumnSpan = 1;
                    cell.Value = "2nd";
                    cell.StringFormat = centerCenterAlignment;
                    cell.Style.Borders = borders;
                    cell.Style.Font = font10Bold;
                    cell.Style.TextBrush = brushBlack;

                    // Row 3 - Method Graphics - Checks
                    pdfGridRow = grid.Rows.Add();
                    pdfGridRow.Height = 22.5f;
                    pdfGridRow2 = grid.Rows.Add();
                    pdfGridRow2.Height = 22.5f;
                    cell = pdfGridRow.Cells[0];
                    cell.ColumnSpan = 2;
                    cell.RowSpan = 2;
                    cell.Style.Borders = borders;
                    PdfGridCellContentList listImageEye = new PdfGridCellContentList();
                    PdfGridCellContent textAndStyleEye = new PdfGridCellContent();
                    textAndStyleEye.Image = imageEye;
                    textAndStyleEye.ImageSize = new SizeF(39,39);
                    listImageEye.List.Add(textAndStyleEye);
                    cell.StringFormat = centerCenterAlignment;
                    cell.Value = listImageEye;

                    cell = pdfGridRow.Cells[2];
                    cell.ColumnSpan = 2;
                    cell.RowSpan = 2;
                    cell.Style.Borders = borders;
                    PdfGridCellContentList listImageHands = new PdfGridCellContentList();
                    PdfGridCellContent textAndStyleHands = new PdfGridCellContent();
                    textAndStyleHands.Image = imageHands;
                    textAndStyleHands.ImageSize = new SizeF(39, 39);
                    listImageHands.List.Add(textAndStyleHands);
                    cell.StringFormat = centerCenterAlignment;
                    cell.Value = listImageHands;

                    cell = pdfGridRow.Cells[4];
                    cell.ColumnSpan = 1;
                    cell.RowSpan = 1;
                    cell.Style.Borders = borders;
                    PdfGridCellContentList listImageCheck = new PdfGridCellContentList();
                    PdfGridCellContent textAndStyleCheck = new PdfGridCellContent();
                    textAndStyleCheck.Image = imageCheck;
                    textAndStyleCheck.ImageSize = new SizeF(20, 20);
                    listImageCheck.List.Add(textAndStyleCheck);
                    cell.StringFormat = centerCenterAlignment;
                    cell.Value = listImageCheck;

tim8w123
 
Posts: 13
Joined: Wed Feb 22, 2023 3:55 pm

Tue Aug 06, 2024 9:27 am

Hello,

​Thanks for your feedback. Based on your smaple code snippet, I can insert an image into the specified cell when using the attached testing code. “gridTest.pdf” is my testing result. You can check it, if there is still any doubts, please feel free to write back.

Sincerely,
Amin
E-iceblue support team
User avatar

Amin.Gan
 
Posts: 164
Joined: Mon Jul 15, 2024 5:40 am

Tue Aug 06, 2024 4:58 pm

Thanks. That worked perfectly!

tim8w123
 
Posts: 13
Joined: Wed Feb 22, 2023 3:55 pm

Wed Aug 07, 2024 1:14 am

Hello,

Thanks for your reply.
I'm glad to hear this news. If you have any other questions, please feel free to write to me.

Sincerely,
Amin
E-iceblue support team
User avatar

Amin.Gan
 
Posts: 164
Joined: Mon Jul 15, 2024 5:40 am

Return to Spire.PDF

cron