コード例 #1
0
 /// <summary>
 /// Opens the given file in memory.
 /// Note:
 /// 1) This call will change the culture prior to instantiating the XL objects !
 /// 2) if it doesn't exist yet, an exception will be thrown.
 /// </summary>
 /// <param name="strFileName">The file to open.  (if it doesn't exist yet, an
 /// exception will be thrown.)</param>
 /// <remarks></remarks>
 public ExcelExportHelper(string strFileName)
 {
     _originalCulture = ExcelExportHelper.GetCurrentCulture();
     ExcelExportHelper.SetExcelCulture();
     // create new instance of the XLS application and open existing worksheet
     _objXLApp   = Activator.CreateInstance(Type.GetTypeFromProgID("Excel.Application", true));
     _objXLBook  = _objXLApp.workbooks.open(strFileName);
     _objXLSheet = _objXLBook.worksheets(1);
 }
コード例 #2
0
        /// <summary>
        /// Creates a NEW workbook in memory.  (This call will change the culture
        /// prior to instantiating the XL objects !)
        /// </summary>
        /// <remarks>This call will change the cultureprior to instantiating the XL objects!</remarks>
        public ExcelExportHelper()
        {
            _originalCulture = ExcelExportHelper.GetCurrentCulture();
            ExcelExportHelper.SetExcelCulture();

            // create new instance of the Excell application and create one worksheet
            _objXLApp   = Activator.CreateInstance(Type.GetTypeFromProgID("Excel.Application", true));
            _objXLBook  = _objXLApp.workbooks.add();
            _objXLSheet = _objXLBook.worksheets(1);
        }