Click here to Skip to main content
15,899,679 members
Home / Discussions / C#
   

C#

 
GeneralCode to: Loop through a datagrid and display its data in a new Excel spreadsheet Pin
Walaza28-Mar-08 2:42
Walaza28-Mar-08 2:42 
GeneralRe: Code to: Loop through a datagrid and display its data in a new Excel spreadsheet Pin
Thomas Stockwell28-Mar-08 3:09
professionalThomas Stockwell28-Mar-08 3:09 
GeneralRe: Code to: Loop through a datagrid and display its data in a new Excel spreadsheet Pin
Walaza28-Mar-08 3:58
Walaza28-Mar-08 3:58 
GeneralRe: Code to: Loop through a datagrid and display its data in a new Excel spreadsheet Pin
Thomas Stockwell28-Mar-08 8:18
professionalThomas Stockwell28-Mar-08 8:18 
GeneralRe: Code to: Loop through a datagrid and display its data in a new Excel spreadsheet Pin
Walaza30-Mar-08 20:17
Walaza30-Mar-08 20:17 
GeneralRe: Code to: Loop through a datagrid and display its data in a new Excel spreadsheet Pin
Thomas Stockwell31-Mar-08 3:46
professionalThomas Stockwell31-Mar-08 3:46 
GeneralRe: Code to: Loop through a datagrid and display its data in a new Excel spreadsheet Pin
Walaza31-Mar-08 4:28
Walaza31-Mar-08 4:28 
GeneralRe: Code to: Loop through a datagrid and display its data in a new Excel spreadsheet Pin
MumbleB28-Mar-08 3:31
MumbleB28-Mar-08 3:31 
I have this code that will export to a CSV file. Maybe it will help.

//Write Header Record
StreamWriter sw = new StreamWriter(@"C:\EPORT\ExportFile_" + DateTime.Today.ToString("ddMMyyyy") + ".csv", false);
DataTable dt = m_dtMobEmail;
int iColCount = dt.Columns.Count;
for (int i = 0; i < iColCount; i++)
{
    sw.Write(@"""{0}""", dt.Columns[i]);
    if (i < iColCount - 1)
    {
        sw.Write(",");
    }
}
sw.Write(sw.NewLine);

//Write all records in the DB
foreach (DataRow dr in dt.Rows)
{
    //Search for all Records with value 0
    if (dr["Exported"].ToString() == "0")
    {
        for (int i = 0; i < iColCount; i++)
        {
            if (!Convert.IsDBNull(dr[i]))
            {
                sw.Write(@"""{0}""", dr[i].ToString());
            }
            if (i < iColCount - 1)
            {
                sw.Write(",");
            }
        }
        sw.Write(sw.NewLine);
    }
}

sw.Close();

GeneralFlashy GDI+ Pin
Reelix28-Mar-08 2:20
Reelix28-Mar-08 2:20 
GeneralRe: Flashy GDI+ Pin
c242328-Mar-08 6:41
c242328-Mar-08 6:41 
QuestionRead,write and save the configuration file likely named as "logger.exe.config"------------- Please Help anyone,its urgent Pin
BhuMan28-Mar-08 2:05
BhuMan28-Mar-08 2:05 
GeneralRe: Read,write and save the configuration file likely named as "logger.exe.config"------------- Please Help anyone,its urgent Pin
Reelix28-Mar-08 2:12
Reelix28-Mar-08 2:12 
GeneralRe: Read,write and save the configuration file likely named as "logger.exe.config"------------- Please Help anyone,its urgent Pin
BhuMan30-Mar-08 18:34
BhuMan30-Mar-08 18:34 
QuestionDDL Creation Pin
kontax28-Mar-08 1:11
kontax28-Mar-08 1:11 
GeneralRe: DDL Creation Pin
Reelix28-Mar-08 1:23
Reelix28-Mar-08 1:23 
GeneralRe: DDL Creation Pin
kontax28-Mar-08 1:29
kontax28-Mar-08 1:29 
GeneralRe: DDL Creation Pin
Reelix28-Mar-08 1:43
Reelix28-Mar-08 1:43 
GeneralRe: DDL Creation Pin
kontax28-Mar-08 2:29
kontax28-Mar-08 2:29 
GeneralRe: DDL Creation Pin
darkelv28-Mar-08 2:38
darkelv28-Mar-08 2:38 
GeneralRe: DDL Creation Pin
kontax28-Mar-08 6:12
kontax28-Mar-08 6:12 
Generalextender desktop Pin
ellllllllie28-Mar-08 0:26
ellllllllie28-Mar-08 0:26 
Generalnested foreach obj1 in obj2 Issue Pin
Harvey Saayman28-Mar-08 0:13
Harvey Saayman28-Mar-08 0:13 
GeneralRe: nested foreach obj1 in obj2 Issue Pin
Bekjong28-Mar-08 0:20
Bekjong28-Mar-08 0:20 
GeneralRe: nested foreach obj1 in obj2 Issue Pin
Harvey Saayman28-Mar-08 0:31
Harvey Saayman28-Mar-08 0:31 
GeneralRe: nested foreach obj1 in obj2 Issue Pin
J4amieC28-Mar-08 1:15
J4amieC28-Mar-08 1:15 

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.