Click here to Skip to main content
15,890,557 members
Home / Discussions / C#
   

C#

 
AnswerRe: C#.net working with windows authenication Pin
Bernhard Hiller25-Aug-11 5:15
Bernhard Hiller25-Aug-11 5:15 
QuestionC#.net working with active directory Pin
dcof23-Aug-11 12:03
dcof23-Aug-11 12:03 
AnswerRe: C#.net working with active directory Pin
Simon Bang Terkildsen23-Aug-11 12:44
Simon Bang Terkildsen23-Aug-11 12:44 
AnswerRe: C#.net working with active directory Pin
SledgeHammer0123-Aug-11 12:49
SledgeHammer0123-Aug-11 12:49 
Questionhow to put condition under the table which is inside the repeater?? Pin
Dhyanga23-Aug-11 11:14
Dhyanga23-Aug-11 11:14 
SuggestionRe: how to put condition under the table which is inside the repeater?? Pin
Simon Bang Terkildsen23-Aug-11 11:28
Simon Bang Terkildsen23-Aug-11 11:28 
GeneralRe: how to put condition under the table which is inside the repeater?? Pin
Dhyanga23-Aug-11 12:06
Dhyanga23-Aug-11 12:06 
QuestionDatagridview to Excel.....Automate Reporting with Timer Pin
PDTUM23-Aug-11 9:48
PDTUM23-Aug-11 9:48 
Good Afternoon,

So, I am using this very nice code to generate Excel spreadsheets from my Datagridview, and I could not be more pleased:

private void CreateExcelReport()
       {
           Microsoft.Office.Interop.Excel.Workbook wBook;
           Microsoft.Office.Interop.Excel.Worksheet wSheet;
           Microsoft.Office.Interop.Excel.Application wApp = new Microsoft.Office.Interop.Excel.Application();
           wApp.Visible = false;
           wBook = wApp.Workbooks.Add(true);
           wSheet = wApp.ActiveSheet;
           try
           {
               for (int i = 0; i < dataGridViewReport.Columns.Count; i++)
               {
                   wSheet.Cells[1, i + 1] = dataGridViewReport.Columns[i].HeaderText;
               }

               for (int i = 0; i < dataGridViewReport.Rows.Count; i++)
               {
                   DataGridViewRow row = dataGridViewReport.Rows[i];
                   for (int j = 0; j < row.Cells.Count; j++)
                   {
                       DataGridViewCell cell = row.Cells[j];
                       try
                       {
                           wSheet.Cells[i + 2, j + 1] = (cell.Value == null) ? "" : cell.Value.ToString();
                       }
                       catch (Exception ex)
                       {
                           MessageBox.Show("Error : " + ex.Message);
                       }
                   }
               }
               wApp.Visible = true;
           }
           catch (Exception ex)
           {
               MessageBox.Show("Error : " + ex.Message);
           }
           wApp.UserControl = true;
       }


Now I would like to have the application run in the background and generate these reports automatically and put them in a folder (anyplace) perhaps by using the timer. I have created the timer part and can call a named file from a database and launch it, however, I do not know where to begin adding onto the Excel code to do it automatically. I need to be able name the file in the spreadsheet, point this script at a location where it can be saved and found later and and have it run automatically as long as the app is running. A piece of code here (perhaps a sample) would be much appreciated. Thank You....Pat
AnswerRe: Datagridview to Excel.....Automate Reporting with Timer Pin
Dalek Dave23-Aug-11 11:33
professionalDalek Dave23-Aug-11 11:33 
GeneralRe: Datagridview to Excel.....Automate Reporting with Timer Pin
PDTUM23-Aug-11 12:32
PDTUM23-Aug-11 12:32 
AnswerRe: Datagridview to Excel.....Automate Reporting with Timer Pin
Mycroft Holmes23-Aug-11 15:09
professionalMycroft Holmes23-Aug-11 15:09 
QuestionReading from a ListBox Pin
Wamuti23-Aug-11 5:57
Wamuti23-Aug-11 5:57 
AnswerRe: Reading from a ListBox [modified] Pin
Herboren23-Aug-11 6:27
Herboren23-Aug-11 6:27 
AnswerRe: Reading from a ListBox Pin
Eddy Vluggen23-Aug-11 11:13
professionalEddy Vluggen23-Aug-11 11:13 
QuestionIE Trickery [modified] Pin
Herboren23-Aug-11 2:35
Herboren23-Aug-11 2:35 
AnswerRe: IE Trickery Pin
Not Active23-Aug-11 3:08
mentorNot Active23-Aug-11 3:08 
GeneralRe: IE Trickery Pin
Herboren23-Aug-11 3:33
Herboren23-Aug-11 3:33 
GeneralRe: IE Trickery Pin
Herboren23-Aug-11 4:08
Herboren23-Aug-11 4:08 
QuestionHow to convert PDF to Flash Book Pin
vj.negi0823-Aug-11 2:31
vj.negi0823-Aug-11 2:31 
AnswerRe: How to convert PDF to Flash Book Pin
BobJanova23-Aug-11 5:08
BobJanova23-Aug-11 5:08 
QuestionVisual Studio build macro [modified] Pin
lukeer22-Aug-11 23:09
lukeer22-Aug-11 23:09 
AnswerRe: Visual Studio build macro Pin
Richard MacCutchan23-Aug-11 0:48
mveRichard MacCutchan23-Aug-11 0:48 
GeneralRe: Visual Studio build macro Pin
lukeer23-Aug-11 3:25
lukeer23-Aug-11 3:25 
Questioncan anyone help me out here with the tutorials of c# classes and arrays and strings as well as exception handling Pin
lokesh battini22-Aug-11 21:50
lokesh battini22-Aug-11 21:50 
AnswerRe: can anyone help me out here with the tutorials of c# classes and arrays and strings as well as exception handling Pin
Wayne Gaylard22-Aug-11 21:59
professionalWayne Gaylard22-Aug-11 21:59 

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.