C# .NET - Print DataGridView Content - Asked By Rajan Singh on 21-Apr-13 05:33 AM

Hi Guys

I'm trying to print DataGridView content but when i'm sending the command it prints Blank Page (Means Nothing on the Page). Can anyone pls help me now..............




Thanks and Regards
Rajan Singh
Danasegarane Arunachalam replied to Rajan Singh on 21-Apr-13 06:24 AM
Here is an example : How Print Datagridview contents

http://code.msdn.microsoft.com/windowsdesktop/CSWinFormPrintDataGridView-75864c45
Danasegarane Arunachalam replied to Rajan Singh on 21-Apr-13 06:24 AM
Another one with example : http://www.codeproject.com/Articles/25638/Printing-a-DataGridView-on-DotNet-Framework
Rick Tipton replied to Rajan Singh on 13-Jun-13 04:45 AM
You can try this component: http://www.gemboxsoftware.com/spreadsheet/overview
and use it to create Excel file from DataGridView in memory. After that you can easily manipulate that data with components simple public API or just use it to print file:

var workbook = new ExcelFile();

// Import DataGridView to a worksheet.
DataGridViewConverter.ImportFromDataGridView(
workbook.Worksheets.Add("SHEET"),
dataGridView,
new ImportFromDataGridViewOptions());

// Print to a default printer.
workbook.Print();