Click here to Skip to main content
15,881,735 members
Home / Discussions / C#
   

C#

 
GeneralSimple C # Solution Help Pin
Hulicat8-Apr-08 9:39
Hulicat8-Apr-08 9:39 
GeneralRe: Simple C # Solution Help Pin
pmarfleet8-Apr-08 11:15
pmarfleet8-Apr-08 11:15 
GeneralRe: Simple C # Solution Help Pin
Hulicat8-Apr-08 11:42
Hulicat8-Apr-08 11:42 
GeneralRe: Simple C # Solution Help Pin
Ravenet8-Apr-08 16:02
Ravenet8-Apr-08 16:02 
GeneralCalling a ASP.NET C# function from javascript Pin
Matt Cavanagh8-Apr-08 9:27
Matt Cavanagh8-Apr-08 9:27 
GeneralRe: Calling a ASP.NET C# function from javascript Pin
Pete O'Hanlon8-Apr-08 9:49
mvePete O'Hanlon8-Apr-08 9:49 
GeneralRe: Calling a ASP.NET C# function from javascript Pin
nelo_8-Apr-08 14:20
nelo_8-Apr-08 14:20 
GeneralExport DataGrid from different dynamically created tabpages to multiple worksheets of an Excel spreasheet Pin
Walaza8-Apr-08 7:09
Walaza8-Apr-08 7:09 
The code I have below only takes data from one dynamically created tabpage (the default)‘s datagrid and exports it to a spreadsheet. I would like the application to take the data from all the dynamically created tabpages’ datagrids and export the data to excel and create a new worksheet for each tabpage as it is exporting. Please help.

Microsoft.Office.Interop.Excel._Application _appClass = new ApplicationClass();
_appClass.Visible = true;

_appClass.Caption = "Exported ECS Errors";

Microsoft.Office.Interop.Excel.Workbook wbk = _appClass.Workbooks.Add(XlWBATemplate.xlWBATWorksheet);

Worksheet obj = (Worksheet)wbk.ActiveSheet;

// get the collection of sheets in the workbook
Microsoft.Office.Interop.Excel.Sheets sheets = wbk.Worksheets;

Range r = (Range)obj.Cells;

try
{
//Load the Headers and make them BOLD
for (int i = 0; i < ((DataGridView)this.dgOutput).Columns.Count; i++)
{
r[1, i + 1] = ((DataGridView)this.dgOutput).Columns[i].HeaderText.ToString();
((Range)r.Cells[1, i + 1]).Font.Bold = true;
}

//Load the data from the datagrid to the new spreadsheet
for (int i = 1; i < ((DataGridView)this.dgOutput).Rows.Count - 1; i++)
{
for (int j = 0; j < ((DataGridView)this.dgOutput).Columns.Count; j++)
{
r[i + 1, j + 1] = ((DataGridView)this.dgOutput).Rows[i].Cells[j].Value.ToString();

//Do the colors
if (((DataGridView)this.dgOutput).Rows[i].Cells[j].Value.ToString() == "Update OK")
{
((Range)r.Cells[i + 1, 1]).Font.Color = Color.Green.G;
}
}
}
}
catch (Exception EX) //user closes the Excel file while it is loading data from the datagrid
{
MessageBox.Show(EX.Message + "The Excel file was closed while loading data from the datagrid.",
"Error : Loading file!!", MessageBoxButtons.OK, MessageBoxIcon.Error);
}

Mvelo Walaza
Developer
Telkom SA

Generalproblems rightformating [modified] Pin
stephan_0078-Apr-08 6:24
stephan_0078-Apr-08 6:24 
GeneralRe: problems rightformating Pin
Luc Pattyn8-Apr-08 6:42
sitebuilderLuc Pattyn8-Apr-08 6:42 
GeneralRe: problems rightformating Pin
stephan_0078-Apr-08 10:03
stephan_0078-Apr-08 10:03 
GeneralChecking integer values and adding same types together Pin
Sharkadder8-Apr-08 6:23
Sharkadder8-Apr-08 6:23 
GeneralRe: Checking integer values and adding same types together Pin
carbon_golem8-Apr-08 7:25
carbon_golem8-Apr-08 7:25 
GeneralRe: Checking integer values and adding same types together Pin
Sharkadder8-Apr-08 7:50
Sharkadder8-Apr-08 7:50 
GeneralRe: Checking integer values and adding same types together Pin
carbon_golem8-Apr-08 16:37
carbon_golem8-Apr-08 16:37 
GeneralRe: Checking integer values and adding same types together Pin
Dave Kreskowiak8-Apr-08 7:55
mveDave Kreskowiak8-Apr-08 7:55 
GeneralRe: Checking integer values and adding same types together [modified] Pin
Sharkadder8-Apr-08 10:53
Sharkadder8-Apr-08 10:53 
General(De)serialization progress Pin
Stevo Z8-Apr-08 6:21
Stevo Z8-Apr-08 6:21 
GeneralRe: (De)serialization progress Pin
Giorgi Dalakishvili8-Apr-08 6:45
mentorGiorgi Dalakishvili8-Apr-08 6:45 
GeneralRe: (De)serialization progress Pin
Stevo Z8-Apr-08 6:58
Stevo Z8-Apr-08 6:58 
GeneralRe: (De)serialization progress Pin
Giorgi Dalakishvili8-Apr-08 7:06
mentorGiorgi Dalakishvili8-Apr-08 7:06 
GeneralRe: (De)serialization progress Pin
Stevo Z8-Apr-08 7:13
Stevo Z8-Apr-08 7:13 
GeneralRe: (De)serialization progress Pin
Giorgi Dalakishvili8-Apr-08 7:50
mentorGiorgi Dalakishvili8-Apr-08 7:50 
GeneralRe: (De)serialization progress Pin
Dave Kreskowiak8-Apr-08 7:24
mveDave Kreskowiak8-Apr-08 7:24 
GeneralRe: (De)serialization progress Pin
Stevo Z8-Apr-08 7:37
Stevo Z8-Apr-08 7:37 

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.