示例#1
0
        public void Generate(string xml, Stream output)
        {
            parser = new ExcelXmlParser();
            try
            {
                parser.setXML(xml);
                createExcel(output);
                setColorProfile();
                headerPrint(parser);

                rowsPrint(parser, output);
                wb.Workbook.Document.Styles.Save();
                // remove repeat foot # charlot
                // footerPrint(parser);
                insertHeader(parser, output);
                insertFooter(parser, output);
                watermarkPrint(parser);
                //// merge head
                //sheet.MergeTwoCells("A1","A3");
                //sheet.Save();
                wb.Dispose();
            }
            catch (Exception e)
            {
                //	    e.printStackTrace();
            }
        }
示例#2
0
        public void Generate(string xml, Stream output)
        {
            parser = new ExcelXmlParser();
            try
            {
                parser.setXML(xml);
                createExcel(output);
                setColorProfile();
                headerPrint(parser);

                rowsPrint(parser, output);
                wb.Workbook.Document.Styles.Save();
                if (PrintFooter)
                {
                    footerPrint(parser);
                }
                insertHeader(parser, output);
                insertFooter(parser, output);
                watermarkPrint(parser);

                wb.Dispose();
            }
            catch (Exception)
            {
                throw;
            }
        }
示例#3
0
        public void TestOpen()
        {
            ExcelDocument doc = null;

            using (MemoryStream ms = new MemoryStream(EXCEL.ToByteArrayFromBase64String()))
            {
                doc = ExcelDocument.OpenDocument(ms);
                Assert.AreEqual(4, doc.GetAllWorksheets().Length);
            }

            ExcelWorksheet worksheet = doc.GetAllWorksheets()[0];
            ExcelFormatter formatter = worksheet.GetFormatterAt(
                new ExcelCellName(new ColumnLetter(Letter.A), 1),
                new ExcelCellName(new ColumnLetter(Letter.C), 3));

            Assert.AreEqual(Color.FromArgb(0, 255, 0, 0), formatter.Background);
            Assert.AreEqual(Color.FromArgb(0, 255, 255, 0), formatter.Foreground);

            doc.Dispose();
        }