Click here to Skip to main content

vasanthkumarmk asked:

Open original thread
I am using windows Forms using C# Language,
 
I have listview, it contains some items when i click the save button the listview items will saves to Excel File. Below is my code of save listview details to Excel.
Microsoft.Office.Interop.Excel.Application xla = new Microsoft.Office.Interop.Excel.Application();
            xla.Visible = true;
           
            Microsoft.Office.Interop.Excel.Workbook wb = xla.Workbooks.Add(Microsoft.Office.Interop.Excel.XlSheetType.xlWorksheet);
            
            Microsoft.Office.Interop.Excel.Worksheet ws = (Microsoft.Office.Interop.Excel.Worksheet)xla.ActiveSheet;
 
            int i = 1;
            int j = 1;
           
            foreach (ListViewItem comp in listView_playlist.Items)
            {
                ws.Cells[i, j] = comp.Text.ToString();         
                //MessageBox.Show(comp.Text.ToString());

                foreach (ListViewItem.ListViewSubItem drv in comp.SubItems)
                {
                    ws.Cells[i, j] = drv.Text.ToString();
                    j++;
                }
                j = 1;
                i++;
            }  

My problem :
Here what my problem is, When i Click the Save button the listview details comes on the Excel page, The Excel page is open stage. I need to click save button in the excel page. Then only it will saved.
 
But I need to save default when i click the Save button. Just we need to enter the file name of save file dialogue box, it will save our local host. without visible the Excel sheet. How can i do this.
 
Regards
Vasanthakumar
Tags: C# (C#3.0, C#4.0)

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the The Code Project Open License (CPOL).



Advertise | Privacy | Mobile
Web03 | 2.8.140415.2 | Last Updated 26 Mar 2009
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Use
Layout: fixed | fluid