TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Goran Bibic
480
2.9k
200.8k
Itext sharp print value from datagrid null c#
Dec 20 2018 3:59 AM
Some help pelease
Error line 48
If is value null error
{"Object reference not set to an instance of an object."}
System.NullReferenceException
System.Windows. Forms.DataGridViewCelll.Value.get returned null
Some help?
private
void
pdfButton_Click(
object
sender, EventArgs e)
{
//Creating iTextSharp Table from the DataTable data
PdfPTable pdfTable =
new
PdfPTable(prijava_radnikaDataGridView.ColumnCount -1);
pdfTable.DefaultCell.Padding = 3;
pdfTable.WidthPercentage = 100;
pdfTable.HorizontalAlignment = Element.ALIGN_CENTER;
pdfTable.DefaultCell.BorderWidth = 1;
//float[] widths = new float[] { 0f, 18f, 40f, 35f, 35f, 25f, 25f, 18f, 40f, 35f };
//pdfTable.SetWidths(widths);
BaseFont bfCalibri = BaseFont.CreateFont(
"c:\\windows\\fonts\\calibri.ttf"
, BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
iTextSharp.text.Font calibri =
new
iTextSharp.text.Font(bfCalibri, 10, iTextSharp.text.Font.NORMAL, iTextSharp.text.BaseColor.WHITE);
iTextSharp.text.Font calibri2 =
new
iTextSharp.text.Font(bfCalibri, 9);
//Adding Header row
foreach
(DataGridViewColumn column
in
prijava_radnikaDataGridView.Columns)
{
if
(column.Index == 1)
{
}
else
{
PdfPCell cell =
new
PdfPCell(
new
Phrase(column.HeaderText, calibri));
cell.BackgroundColor =
new
BaseColor(89, 135, 178);
cell.VerticalAlignment = Element.ALIGN_MIDDLE;
pdfTable.AddCell(cell);
}
}
//Adding DataRow
foreach
(DataGridViewRow row
in
prijava_radnikaDataGridView.Rows)
{
foreach
(DataGridViewCell cell
in
row.Cells)
{
if
(cell.ColumnIndex == 1 )
{
PdfPCell cell2 =
new
PdfPCell(
new
Phrase(cell.Value.ToString().Split(
' '
)[0], calibri));
pdfTable.AddCell(cell2);
}
else
{
PdfPCell cell2 =
new
PdfPCell(
new
Phrase(cell.Value.ToString(), calibri));
pdfTable.AddCell(cell2);
}
}
}
etc.....code....<<
}
Reply
Answers (
2
)
CRUD operation with Save and Update operation at Same button
How to get list of bookmarks in word using OpenXml