如何使用itextsharp为同一个单元格添加值? [英] how to add value to the same cell using itextsharp?
本文介绍了如何使用itextsharp为同一个单元格添加值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
i在pdf导出中创建了如下单元格。
PdfPCell subCell1 = < span class =code-keyword> new PdfPCell();
subCell1.Phrase = new 短语(dtResult.Rows [i] [ 5 ]。ToString ()+ : - + dtResult.Rows [i] [ 6 ]。ToString(),FontFactory.GetFont( verdana, 8 ,BaseColor.BLACK));
subTable1.AddCell(subCell1);
我想将下一个数据添加到同一个单元格而不创建新单元格。如何解决这个问题?
谢谢..
解决方案
使用StringBuilder类 [ ^ ]创建要保存的字符串单个单元格。
StringBuilder sb = new StringBuilder();
PdfPCell subCell1 = new PdfPCell();
for (...)
{
sb.AppendLine( String .Concat(dtResult.Rows [i] [ 5 ]。ToString(), : - ,dtResult.Rows [i] [ 6 ]。ToString()));
}
subCell1.Phrase = new 短语(sb.ToString(),FontFactory.GetFont( verdana, 8 ,BaseColor.BLACK));
subTable1.AddCell(subCell1);
Hi,
i created a cell as below in pdf export.
PdfPCell subCell1 = new PdfPCell();
subCell1.Phrase = new Phrase(dtResult.Rows[i][5].ToString() + ":-" + dtResult.Rows[i][6].ToString(), FontFactory.GetFont("verdana", 8, BaseColor.BLACK));
subTable1.AddCell(subCell1);
i want to add the next data to the same cell without creating new cell. how to solve this?
Thanks..
解决方案
Use StringBuilder class[^] to create string you want to save in single cell.
StringBuilder sb = new StringBuilder(); PdfPCell subCell1 = new PdfPCell(); for (...) { sb.AppendLine(String.Concat(dtResult.Rows[i][5].ToString(),":-",dtResult.Rows[i][6].ToString())); } subCell1.Phrase = new Phrase(sb.ToString(), FontFactory.GetFont("verdana", 8, BaseColor.BLACK)); subTable1.AddCell(subCell1);
这篇关于如何使用itextsharp为同一个单元格添加值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文