Reputation: 377
Sorry for my title, I can't think of a good one. Anyway. Can someone help me give an idea how to achieve a format like this? what to use? (ex: richtextbox) how to create the cell borders? and it should also be printable.
Upvotes: 2
Views: 1033
Reputation: 2311
Have you heard about iTextSharp? You can create tables with itextsharp. But you need to save it as pdf format. So the idea here is create a table format like that and save it as pdf then open it to a webrowser or some kind of a pdf renderer by then you will be able to print it as well.
Here's a simple code for creating table:
private bool Test(string pdf_file)
{
bool ret = false;
Document doc = new Document(PageSize.A4);
try
{
PdfWriter writer = PdfWriter.GetInstance(doc, new FileStream(pdf_file, FileMode.Create));
doc.Open();
PdfPTable table = new PdfPTable(3);
PdfPCell cell = new PdfPCell(new Phrase("Header Column"));
cell.Colspan = 3;
cell.HorizontalAlignment = 1;
table.AddCell(cell);
table.AddCell("row1:col1");
table.AddCell("row1:col2");
table.AddCell("row1:col3");
doc.Add(table);
ret = true;
}
catch (DocumentException de)
{
MessageBox.Show(de.Message);
}
catch (IOException ioe)
{
MessageBox.Show(ioe.Message);
}
doc.Close();
if(ret)
MessageBox.Show("File has been created");
return ret;
}
PDF Output:
Upvotes: 0
Reputation: 2204
I think you should Create Local Report (.rdlc) in Report Viewer to do that. Using This the user can extract your data in different format(Excel,PDF and CSV).
Regards
Upvotes: 0
Reputation: 10351
Can you just use a DataGridView? Seems a lot easier then trying to maintain consistent column widths.
Upvotes: 1