来自datagrid的多个日期时间itextsharp PDF C# [英] Multiple datetime from datagrid itextsharp PDF C#
本文介绍了来自datagrid的多个日期时间itextsharp PDF C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
I have solution and work fine
I need in ,,if (c == 2),, to add multiple columns with date and time...some help?
我的尝试:
What I have tried:
//Adding DataRow
foreach (DataGridViewRow row in mp_racun_listaDataGridView.Rows)
{
int c = 0;
foreach (DataGridViewCell cell in row.Cells)
{
if (c == 2)
{
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);
}
c++;
}
}
推荐答案
假设您要在空格字符上拆分单元格值,并添加每个part作为新单元格:
Assuming you want to split the cell value on the space character, and add each part as a new cell:
if (c == 2)
{
string[] parts = cell.Value.ToString().Split(' ');
foreach (string value in parts)
{
PdfPCell cell2 = new PdfPCell(new Phrase(value, calibri));
pdfTable.AddCell(cell2);
}
}
如果这不是你想要做的,或者它不起作用,那么你需要提供更多细节。
If that's not what you're trying to do, or if it doesn't work, then you'll need to provide more details.
这篇关于来自datagrid的多个日期时间itextsharp PDF C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文