Click here to Skip to main content
15,881,801 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I am creating an Excel file in an WinForm app (VS2008) in runtime. I am exporting some data into it from datagridview. After export, i would like to show this file in excel, but dont want to save anywhere. My goal is to use it as an alternative of creating report in crystal. Is it possible ?
Posted
Comments
[no name] 14-Nov-12 1:37am    
I think you need a excel spreadsheet viewer.

1 solution

C#
//Create excel object and load it.
 m_objExcel1 = new Excel.Application();
  m_objBook1 = (Excel.Workbook)m_objExcel1.Workbooks.Open(@"\FM-temp.xls", m_objOpt, m_objOpt, m_objOpt, m_objOpt, m_objOpt, m_objOpt, m_objOpt, m_objOpt, m_objOpt, m_objOpt, m_objOpt, m_objOpt, m_objOpt, m_objOpt);
                    m_objSheets1 = (Excel.Sheets)m_objBook1.Worksheets;
                    m_objSheet1 = (Excel._Worksheet)(m_objSheets1.get_Item(1));

                  //If you add following line to the excel object it will view in the explorer.

                    m_objBook1.Application.Visible = true;
        
                  //then simply add values to the fields. You can view it while adding the values.

  Excel.Range oRangeI = (Excel.Range)m_objSheet1.get_Range("B" + i.ToString(), m_objOpt);
                        oRangeI.Value2 = f.Name;
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900