Beispiel #1
0
        /// <summary>
        /// Creates a stub Workbook from the supplied records,
        /// suitable for use with the {@link HSSFFormulaParser}
        /// </summary>
        /// <param name="externs">The ExternSheetRecords in your file</param>
        /// <param name="bounds">The BoundSheetRecords in your file</param>
        /// <param name="sst">TThe SSTRecord in your file.</param>
        /// <returns>A stub Workbook suitable for use with HSSFFormulaParser</returns>
        public static Workbook CreateStubWorkbook(ExternSheetRecord[] externs,
                                                  BoundSheetRecord[] bounds, SSTRecord sst)
        {
            List <Record> wbRecords = new List <Record>();

            // Core Workbook records go first
            if (bounds != null)
            {
                for (int i = 0; i < bounds.Length; i++)
                {
                    wbRecords.Add(bounds[i]);
                }
            }
            if (sst != null)
            {
                wbRecords.Add(sst);
            }

            // Now we can have the ExternSheetRecords,
            //  preceded by a SupBookRecord
            if (externs != null)
            {
                wbRecords.Add(SupBookRecord.CreateInternalReferences(
                                  (short)externs.Length));
                for (int i = 0; i < externs.Length; i++)
                {
                    wbRecords.Add(externs[i]);
                }
            }

            // Finally we need an EoF record
            wbRecords.Add(EOFRecord.instance);

            return(Workbook.CreateWorkbook(wbRecords));
        }
Beispiel #2
0
        public void CreateExistedFileFail()
        {
            Workbook wb = new Workbook();

            wb.CreateWorkbook();
            Worksheet ws = wb.CreateWorksheet("SomeSheet");

            wb.SaveAs(@"\\192.168.16.50\bazaotd\Давыдов Д.В\CreateTest.xlsx");
            wb.Quit();
        }
Beispiel #3
0
        public void CreateFileTest()
        {
            Workbook wb = new Workbook();

            try
            {
                wb.CreateWorkbook();
                Worksheet ws = wb.CreateWorksheet("SomeSheet");
                wb.SaveAs(@"\\192.168.16.50\bazaotd\Давыдов Д.В\CreateTest.xlsx");
            }
            catch (FileExistsException e)
            {
            }
            finally
            {
                wb.Quit();
            }
        }