Esempio n. 1
0
File: Program.cs Progetto: icune/R
        static void Main(string[] args)
        {
            try
            {
                Book book = new BinBook();

                Font font = book.addFont();
                font.size = 36;

                Format format = book.addFormat();
                format.alignH = AlignH.ALIGNH_CENTER;
                format.setBorder(BorderStyle.BORDERSTYLE_MEDIUMDASHDOTDOT);
                format.setBorderColor(Color.COLOR_RED);
                format.font = font;

                Sheet sheet = book.addSheet("Sheet1");
                sheet.writeStr(2, 1, "Format", format);
                sheet.setCol(1, 1, 25);

                book.save("format.xls");

                System.Diagnostics.Process.Start("format.xls");
            }
            catch(System.Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
Esempio n. 2
0
File: Program.cs Progetto: icune/R
        static void Main(string[] args)
        {
            try
            {
                Book book = new BinBook();

                int f1 = book.addCustomNumFormat("0.0");
                int f2 = book.addCustomNumFormat("0.00");
                int f3 = book.addCustomNumFormat("0.000");
                int f4 = book.addCustomNumFormat("0.0000");
                int f5 = book.addCustomNumFormat("#,###.00 $");
                int f6 = book.addCustomNumFormat("#,###.00 $[Black][<1000];#,###.00 $[Red][>=1000]");

                Format format1 = book.addFormat();
                format1.setNumFormat(f1);

                Format format2 = book.addFormat();
                format2.setNumFormat(f2);

                Format format3 = book.addFormat();
                format3.setNumFormat(f3);

                Format format4 = book.addFormat();
                format4.setNumFormat(f4);

                Format format5 = book.addFormat();
                format5.setNumFormat(f5);

                Format format6 = book.addFormat();
                format6.setNumFormat(f6);

                Sheet sheet = book.addSheet("Custom formats");
                sheet.setCol(0, 20);

                sheet.writeNum(2, 0, 25.718, format1);
                sheet.writeNum(3, 0, 25.718, format2);
                sheet.writeNum(4, 0, 25.718, format3);
                sheet.writeNum(5, 0, 25.718, format4);

                sheet.writeNum(7, 0, 1800.5, format5);

                sheet.writeNum(9, 0, 500, format6);
                sheet.writeNum(10, 0, 1600, format6);

                book.save("custom.xls");

                System.Diagnostics.Process.Start("custom.xls");
            }
            catch (System.Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
Esempio n. 3
0
File: Program.cs Progetto: icune/R
        static void Main(string[] args)
        {
            try
            {
                Book book = new BinBook();
                book.load("example.xls");
                Sheet sheet = book.getSheet(0);
                double d = sheet.readNum(3, 1);
                sheet.writeNum(3, 1, d * 2);
                sheet.writeStr(4, 1, "new string");
                book.save("example.xls");

                System.Diagnostics.Process.Start("example.xls");
            }
            catch (System.Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
Esempio n. 4
0
File: Program.cs Progetto: icune/R
        static void Main(string[] args)
        {
            try
            {
                Book book = new BinBook();
                book.load("example.xls");
                Sheet sheet = book.getSheet(0);

                string s = sheet.readStr(2, 1);
                Console.WriteLine(s);

                double d = sheet.readNum(3, 1);
                Console.WriteLine(d);
            }
            catch (System.Exception e)
            {
                Console.WriteLine(e.Message);
            }

            Console.Write("\nPress any key to exit...");
            Console.ReadKey();
        }
Esempio n. 5
0
File: Program.cs Progetto: icune/R
        static void Main(string[] args)
        {
            try
            {
                Book book = new BinBook();
                Sheet sheet = book.addSheet("Sheet1");

                sheet.writeStr(2, 1, "Hello, World !");
                sheet.writeNum(3, 1, 1000);

                Format dateFormat = book.addFormat();
                dateFormat.setNumFormat(NumFormat.NUMFORMAT_DATE);
                sheet.writeNum(4, 1, book.datePack(2008, 4, 29), dateFormat);
                sheet.setCol(1, 1, 12);

                book.save("example.xls");

                System.Diagnostics.Process.Start("example.xls");
            }
            catch (System.Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
Esempio n. 6
0
File: Program.cs Progetto: icune/R
        static void test(int number)
        {
            Console.WriteLine("---------------------------------");
            if (number == 1)
            {
                Console.WriteLine("           strings               ");
            }
            else
            {
                Console.WriteLine("           numbers               ");
            }
            Console.WriteLine("---------------------------------\n");

            Book book = new BinBook();
            Sheet sheet = book.addSheet("Sheet1");

            Console.Write("writing {0:#,###} cells... ", (maxRow - 1) * maxCol);
            DateTime t1 = DateTime.Now;

            if (number == 1)
            {
                for (int row = 1; row < maxRow; ++row)
                {
                    for (int col = 0; col < maxCol; ++col)
                    {
                        sheet.writeStr(row, col, makeString());
                    }
                }
            }
            else
            {
                for (int row = 1; row < maxRow; ++row)
                {
                    for (int col = 0; col < maxCol; ++col)
                    {
                        sheet.writeNum(row, col, 1234);
                    }
                }
            }

            Console.WriteLine("ok");

            DateTime t2 = DateTime.Now;
            TimeSpan d = t2 - t1;
            Console.WriteLine("time: {0} sec", d.TotalSeconds);

            double n = (maxRow - 1) * maxCol / d.TotalSeconds;
            Console.WriteLine("speed: {0:#,###} cells/sec", n);
            Console.WriteLine();

            Console.Write("saving... ");

            if (number == 1) {
                book.save("perfstr.xls");
            } else {
                book.save("perfnum.xls");
            }

            Console.WriteLine("ok");

            DateTime t3 = DateTime.Now;
            Console.WriteLine("time: {0} sec", (t3 - t2).TotalSeconds);
            Console.WriteLine();

            Console.WriteLine("total time: {0} sec", (t3 - t1).TotalSeconds);

            d = t3 - t1;
            n = (maxRow - 1) * maxCol / d.TotalSeconds;
            Console.WriteLine("speed with saving on disk: {0:#,###} cells/sec\n", n);

            GC.Collect();
            GC.WaitForPendingFinalizers();
            GC.Collect();
        }
Esempio n. 7
0
        static void Main(string[] args)
        {
            try
            {
                Book book = new BinBook();

                Font boldFont = book.addFont();
                boldFont.bold = true;

                Font titleFont = book.addFont();
                titleFont.name = "Arial Black";
                titleFont.size = 16;

                Format titleFormat = book.addFormat();
                titleFormat.font = titleFont;

                Format headerFormat = book.addFormat();
                headerFormat.alignH = AlignH.ALIGNH_CENTER;
                headerFormat.setBorder(BorderStyle.BORDERSTYLE_THIN);
                headerFormat.font = boldFont;
                headerFormat.fillPattern = FillPattern.FILLPATTERN_SOLID;
                headerFormat.patternForegroundColor = Color.COLOR_TAN;

                Format descriptionFormat = book.addFormat();
                descriptionFormat.borderLeft = BorderStyle.BORDERSTYLE_THIN;

                Format amountFormat = book.addFormat();
                amountFormat.setNumFormat(NumFormat.NUMFORMAT_CURRENCY_NEGBRA);
                amountFormat.borderLeft = BorderStyle.BORDERSTYLE_THIN;
                amountFormat.borderRight = BorderStyle.BORDERSTYLE_THIN;

                Format totalLabelFormat = book.addFormat();
                totalLabelFormat.borderTop = BorderStyle.BORDERSTYLE_THIN;
                totalLabelFormat.alignH = AlignH.ALIGNH_RIGHT;
                totalLabelFormat.font = boldFont;

                Format totalFormat = book.addFormat();
                totalFormat.setNumFormat(NumFormat.NUMFORMAT_CURRENCY_NEGBRA);
                totalFormat.setBorder(BorderStyle.BORDERSTYLE_THIN);
                totalFormat.font = boldFont;
                totalFormat.fillPattern = FillPattern.FILLPATTERN_SOLID;
                totalFormat.patternForegroundColor = Color.COLOR_YELLOW;

                Format signatureFormat = book.addFormat();
                signatureFormat.alignH = AlignH.ALIGNH_CENTER;
                signatureFormat.borderTop = BorderStyle.BORDERSTYLE_THIN;

                Sheet sheet = book.addSheet("Invoice");

                sheet.writeStr(2, 1, "Invoice No. 3568", titleFormat);

                sheet.writeStr(4, 1, "Name: John Smith");
                sheet.writeStr(5, 1, "Address: San Ramon, CA 94583 USA");

                sheet.writeStr(7, 1, "Description", headerFormat);
                sheet.writeStr(7, 2, "Amount", headerFormat);

                sheet.writeStr(8, 1, "Ball-Point Pens", descriptionFormat);
                sheet.writeNum(8, 2, 85, amountFormat);
                sheet.writeStr(9, 1, "T-Shirts", descriptionFormat);
                sheet.writeNum(9, 2, 150, amountFormat);
                sheet.writeStr(10, 1, "Tea cups", descriptionFormat);
                sheet.writeNum(10, 2, 45, amountFormat);

                sheet.writeStr(11, 1, "Total:", totalLabelFormat);
                sheet.writeNum(11, 2, 280, totalFormat);

                sheet.writeStr(14, 2, "Signature", signatureFormat);

                sheet.setCol(1, 1, 40);
                sheet.setCol(2, 2, 15);
                
                book.save("invoice.xls");

                System.Diagnostics.Process.Start("invoice.xls");                
            }
            catch (System.Exception e)
            {
                Console.WriteLine(e.Message);
            }            
        }