Click here to Skip to main content
15,914,016 members
Home / Discussions / C#
   

C#

 
Suggestionproject Pin
Apurba Chatterjee11-Apr-12 8:18
Apurba Chatterjee11-Apr-12 8:18 
AnswerRe: project Pin
ZurdoDev11-Apr-12 8:33
professionalZurdoDev11-Apr-12 8:33 
GeneralRe: project Pin
Big Daddy Farang11-Apr-12 9:18
Big Daddy Farang11-Apr-12 9:18 
JokeRe: project Pin
ZurdoDev11-Apr-12 9:19
professionalZurdoDev11-Apr-12 9:19 
JokeRe: project Pin
V.11-Apr-12 21:02
professionalV.11-Apr-12 21:02 
GeneralRe: project Pin
ZurdoDev12-Apr-12 1:47
professionalZurdoDev12-Apr-12 1:47 
GeneralRe: project Pin
RobCroll11-Apr-12 18:52
RobCroll11-Apr-12 18:52 
QuestionExport Mutiple DataGridView to Multiple Sheets in an Excel File ... Pin
nassimnastaran11-Apr-12 8:15
nassimnastaran11-Apr-12 8:15 
Hi all !
I want o export 2 datagridview in 2 sheets of An Excel File .
some code for one DataGridView is Here :
C#
...
Microsoft.Office.Interop.Excel.Worksheet mySheetInputData = null;
try
{
   mySheetInputData = (Microsoft.Office.Interop.Excel.Worksheet)ExWorkBookInputData.Sheets["Sheet1"];

    mySheetInputData = (Microsoft.Office.Interop.Excel.Worksheet)ExWorkBookInputData.ActiveSheet;
    mySheetInputData.Name = "First Sheet";
 // storing header part in Excel
    for (int i = 1; i < dgv.Columns.Count + 1; i++)
    {
        mySheetInputData.Cells[1, i + 1] = dgv.Columns[i - 1].HeaderText;
    }
    for (int j = 1; j < dgv.Rows.Count + 1; j++)
    {
        mySheetInputData.Cells[j + 1, 1] = dgv.Rows[j - 1].HeaderCell.Value.ToString();
    }
    // storing Each row and column value to excel sheet

    for (int i = 0; i < dgv.Rows.Count; i++)
    {
        for (int j = 0; j < dgv.Columns.Count; j++)
        {
            mySheetInputData.Cells[i + 2, j + 2] = dgv.Rows[i].Cells[j].Value.ToString();
        }
    }
    //save the application
    string fileNameInputData = String.Empty;
    SaveFileDlgInputData.Filter = "Excel Files (*.xlsx)|*.xlsx";
    SaveFileDlgInputData.FilterIndex = 2;
    SaveFileDlgInputData.RestoreDirectory = true;

    if (SaveFileDlgInputData.ShowDialog() == DialogResult.OK)
    {
        fileNameInputData = SaveFileDlgInputData.FileName;
        ExWorkBookInputData.SaveAs(fileNameInputData, Type.Missing, Type.Missing,
            Type.Missing, Type.Missing, Type.Missing,
            Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlExclusive,
            Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);

    }
    else
        return;
        ...



thanks for any help
QuestionPlease help me on using this codeproject Pin
aquahoya11-Apr-12 6:39
aquahoya11-Apr-12 6:39 
AnswerRe: Please help me on using this codeproject Pin
Richard MacCutchan11-Apr-12 6:55
mveRichard MacCutchan11-Apr-12 6:55 
AnswerRe: Please help me on using this codeproject Pin
Big Daddy Farang11-Apr-12 7:24
Big Daddy Farang11-Apr-12 7:24 
AnswerRe: still having problem =( Pin
aquahoya11-Apr-12 7:46
aquahoya11-Apr-12 7:46 
GeneralRe: still having problem =( Pin
Big Daddy Farang11-Apr-12 9:07
Big Daddy Farang11-Apr-12 9:07 
GeneralRe: still having problem =( Pin
aquahoya11-Apr-12 9:34
aquahoya11-Apr-12 9:34 
GeneralRe: OMG u did it!!! =) Pin
aquahoya11-Apr-12 9:57
aquahoya11-Apr-12 9:57 
GeneralRe: OMG u did it!!! =) Pin
Big Daddy Farang11-Apr-12 10:03
Big Daddy Farang11-Apr-12 10:03 
QuestionDo u find c# descent? Pin
Mark Kruger11-Apr-12 5:13
Mark Kruger11-Apr-12 5:13 
AnswerRe: Do u find c# descent? Pin
BobJanova11-Apr-12 5:21
BobJanova11-Apr-12 5:21 
AnswerRe: Do u find c# descent? Pin
PIEBALDconsult11-Apr-12 5:41
mvePIEBALDconsult11-Apr-12 5:41 
GeneralRe: Do u find c# descent? Pin
Mark Kruger11-Apr-12 6:13
Mark Kruger11-Apr-12 6:13 
AnswerRe: Do u find c# descent? Pin
Eddy Vluggen11-Apr-12 7:04
professionalEddy Vluggen11-Apr-12 7:04 
GeneralRe: Do u find c# descent? Pin
Mark Kruger11-Apr-12 7:38
Mark Kruger11-Apr-12 7:38 
GeneralRe: Do u find c# descent? Pin
BobJanova11-Apr-12 23:52
BobJanova11-Apr-12 23:52 
GeneralRe: Do u find c# descent? Pin
Mark Kruger12-Apr-12 1:29
Mark Kruger12-Apr-12 1:29 
AnswerRe: Do u find c# descent? Pin
V.11-Apr-12 21:04
professionalV.11-Apr-12 21:04 

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.