Click here to Skip to main content
15,923,222 members
Home / Discussions / C#
   

C#

 
AnswerRe: Dot-Matrix Printer Resolution Problem Pin
OriginalGriff16-May-11 22:11
mveOriginalGriff16-May-11 22:11 
GeneralRe: Dot-Matrix Printer Resolution Problem Pin
ismail2016-May-11 22:17
ismail2016-May-11 22:17 
GeneralRe: Dot-Matrix Printer Resolution Problem Pin
OriginalGriff16-May-11 22:29
mveOriginalGriff16-May-11 22:29 
GeneralRe: Dot-Matrix Printer Resolution Problem Pin
ismail2016-May-11 22:31
ismail2016-May-11 22:31 
GeneralRe: Dot-Matrix Printer Resolution Problem Pin
OriginalGriff16-May-11 22:40
mveOriginalGriff16-May-11 22:40 
GeneralRe: Dot-Matrix Printer Resolution Problem Pin
ismail2016-May-11 22:50
ismail2016-May-11 22:50 
GeneralRe: Dot-Matrix Printer Resolution Problem Pin
OriginalGriff16-May-11 23:04
mveOriginalGriff16-May-11 23:04 
GeneralRe: Dot-Matrix Printer Resolution Problem Pin
ismail2016-May-11 23:15
ismail2016-May-11 23:15 
AnswerRe: Dot-Matrix Printer Resolution Problem Pin
OriginalGriff16-May-11 23:33
mveOriginalGriff16-May-11 23:33 
AnswerRe: Dot-Matrix Printer Resolution Problem Pin
Luc Pattyn16-May-11 22:54
sitebuilderLuc Pattyn16-May-11 22:54 
GeneralRe: Dot-Matrix Printer Resolution Problem Pin
ismail2016-May-11 23:08
ismail2016-May-11 23:08 
GeneralRe: Dot-Matrix Printer Resolution Problem Pin
Luc Pattyn16-May-11 23:15
sitebuilderLuc Pattyn16-May-11 23:15 
GeneralRe: Dot-Matrix Printer Resolution Problem Pin
ismail2016-May-11 23:20
ismail2016-May-11 23:20 
AnswerRe: Dot-Matrix Printer Resolution Problem Pin
Luc Pattyn16-May-11 23:43
sitebuilderLuc Pattyn16-May-11 23:43 
GeneralRe: Dot-Matrix Printer Resolution Problem Pin
ismail2016-May-11 23:56
ismail2016-May-11 23:56 
GeneralRe: Dot-Matrix Printer Resolution Problem Pin
Luc Pattyn17-May-11 0:18
sitebuilderLuc Pattyn17-May-11 0:18 
GeneralRe: Dot-Matrix Printer Resolution Problem Pin
ismail2017-May-11 0:36
ismail2017-May-11 0:36 
GeneralRe: Dot-Matrix Printer Resolution Problem Pin
Luc Pattyn17-May-11 0:57
sitebuilderLuc Pattyn17-May-11 0:57 
GeneralRe: Dot-Matrix Printer Resolution Problem Pin
ismail2017-May-11 1:00
ismail2017-May-11 1:00 
GeneralRe: Dot-Matrix Printer Resolution Problem Pin
Luc Pattyn17-May-11 1:05
sitebuilderLuc Pattyn17-May-11 1:05 
GeneralRe: Dot-Matrix Printer Resolution Problem Pin
ismail2017-May-11 1:11
ismail2017-May-11 1:11 
GeneralRe: Dot-Matrix Printer Resolution Problem Pin
ismail2017-May-11 1:29
ismail2017-May-11 1:29 
GeneralRe: Dot-Matrix Printer Resolution Problem Pin
ismail2017-May-11 2:08
ismail2017-May-11 2:08 
AnswerRe: Dot-Matrix Printer Resolution Problem Pin
Shameel17-May-11 4:15
professionalShameel17-May-11 4:15 
QuestionExport C# Windows Datagridview to excel Pin
sumit703416-May-11 19:09
sumit703416-May-11 19:09 
Hi I want to export Datagridview to excel. I have formatted my datagridview such that he negative values are shown as red, some values are bold and other formatting styles are applied. I want when I export it to Excel then it export with same formatted type.

Currently I Am using the below function to export. But unable to export with formatting.

private void exportAsExcel()
{
Microsoft.Office.Interop.Excel._Application app = new Microsoft.Office.Interop.Excel.Application();
// creating new WorkBook within Excel application
Microsoft.Office.Interop.Excel._Workbook workbook = app.Workbooks.Add(Type.Missing);
// creating new Excelsheet in workbook
Microsoft.Office.Interop.Excel._Worksheet worksheet = null;
// see the excel sheet behind the program
//Funny
app.Visible = true;
// get the reference of first sheet. By default its name is Sheet1.
// store its reference to worksheet
try
{
//Fixed:(Microsoft.Office.Interop.Excel.Worksheet)
worksheet = (Microsoft.Office.Interop.Excel.Worksheet)workbook.Sheets["Sheet1"];
worksheet = (Microsoft.Office.Interop.Excel.Worksheet)workbook.ActiveSheet;
// changing the name of active sheet
worksheet.Name = "Sheet1";
// storing header part in Excel
for (int i = 1; i < dgvDetails.Columns.Count + 1; i++)
{
worksheet.Cells[1, i] = dgvDetails.Columns[i - 1].HeaderText;
}
worksheet.get_Range("A1", "AZ1").Font.Bold = true;
worksheet.get_Range("A1", "A" + (dgvDetails.RowCount + 2).ToString()).Font.Bold = true;
// storing Each row and column value to excel sheet
for (int i = 0; i < dgvDetails.Rows.Count; i++)
{
for (int j = 0; j < dgvDetails.Columns.Count; j++)
{
worksheet.Cells[i + 2, j + 1] = dgvDetails.Rows[i].Cells[j].Value.ToString();
}
}

}
catch (System.Exception ex)
{

}
finally
{
app.Quit();
workbook = null;
app = null;
}
}
Thanks in advance

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.