Beispiel #1
0
        public static void Main(string[] Args)
        {
            if (Args.Length == 0)
            {
                displayHelp();
                return;
            }

            if (Args[0] == "-help" || Args[0] == "-h")
            {
                displayHelp();
                return;
            }

            if (Args[0] == "-version")
            {
                Console.WriteLine("v" + Workbook.getVersion());
                return;
            }

            bool   write        = false;
            bool   readwrite    = false;
            bool   formulas     = false;
            bool   biffdump     = false;
            bool   jxlversion   = false;
            bool   propertysets = false;
            bool   features     = false;
            bool   escher       = false;
            bool   escherdg     = false;
            string file         = Args[0];
            string outputFile   = null;
            string propertySet  = null;

            if (Args[0] == "-write")
            {
                write = true;
                file  = Args[1];
            }
            else if (Args[0] == "-formulas")
            {
                formulas = true;
                file     = Args[1];
            }
            else if (Args[0] == "-features")
            {
                features = true;
                file     = Args[1];
            }
            else if (Args[0] == "-escher")
            {
                escher = true;
                file   = Args[1];
            }
            else if (Args[0] == "-escherdg")
            {
                escherdg = true;
                file     = Args[1];
            }
            else if (Args[0] == "-biffdump" || Args[0] == "-bd")
            {
                biffdump = true;
                file     = Args[1];
            }
            else if (Args[0] == "-wa")
            {
                jxlversion = true;
                file       = Args[1];
            }
            else if (Args[0] == "-ps")
            {
                propertysets = true;
                file         = Args[1];

                if (Args.Length > 2)
                {
                    propertySet = Args[2];
                }

                if (Args.Length == 4)
                {
                    outputFile = Args[3];
                }
            }
            else if (Args[0] == "-readwrite" || Args[0] == "-rw")
            {
                readwrite  = true;
                file       = Args[1];
                outputFile = Args[2];
            }
            else
            {
                file = Args[Args.Length - 1];
            }

            string encoding   = "UTF8";
            int    format     = CSVFormat;
            bool   formatInfo = false;
            bool   hideCells  = false;

            if (write == false &&
                readwrite == false &&
                formulas == false &&
                biffdump == false &&
                jxlversion == false &&
                propertysets == false &&
                features == false &&
                escher == false &&
                escherdg == false)
            {
                for (int i = 0; i < Args.Length - 1; i++)
                {
                    if (Args[i] == "-unicode")
                    {
                        encoding = "UnicodeBig";
                    }
                    else if (Args[i] == "-xml")
                    {
                        format = XMLFormat;
                    }
                    else if (Args[i] == "-csv")
                    {
                        format = CSVFormat;
                    }
                    else if (Args[i] == "-format")
                    {
                        formatInfo = true;
                    }
                    else if (Args[i] == "-hide")
                    {
                        hideCells = true;
                    }
                    else
                    {
                        Console.WriteLine("Command format:  CSV [-unicode] [-xml|-csv] excelfile");
                        return;
                    }
                }
            }

            try
            {
                if (write)
                {
                    Write w = new Write(file);
                    w.write();
                }
                else if (readwrite)
                {
                    ReadWrite rw = new ReadWrite(file, outputFile);
                    rw.readWrite();
                }
                else if (formulas)
                {
                    Workbook w = Workbook.getWorkbook(new FileInfo(file));
                    Formulas f = new Formulas(w, Console.Out, encoding);
                    w.close();
                }
                else if (features)
                {
                    Workbook w = Workbook.getWorkbook(new FileInfo(file));
                    Features f = new Features(w, Console.Out, encoding);
                    w.close();
                }
                else if (escher)
                {
                    Workbook w = Workbook.getWorkbook(new FileInfo(file));
                    Escher   f = new Escher(w, Console.Out, encoding);
                    w.close();
                }
                else if (escherdg)
                {
                    Workbook           w = Workbook.getWorkbook(new FileInfo(file));
                    EscherDrawingGroup f = new EscherDrawingGroup(w, Console.Out, encoding);
                    w.close();
                }
                else if (biffdump)
                {
                    BiffDump bd = new BiffDump(new FileInfo(file), Console.Out);
                }
                else if (jxlversion)
                {
                    WriteAccess bd = new WriteAccess(new FileInfo(file), Console.Out);
                }
                else if (propertysets)
                {
                    TextWriter os = Console.Out;
                    //if (outputFile != null)
                    //    os = new TextWriter((outputFile, FileMode.Create));
                    PropertySetsReader psr = new PropertySetsReader(new FileInfo(file), propertySet, os);
                }
                else
                {
                    Workbook w = Workbook.getWorkbook(new FileInfo(file));

                    //        findTest(w);

                    if (format == CSVFormat)
                    {
                        CSV csv = new CSV(w, Console.Out, encoding, hideCells);
                    }
                    else if (format == XMLFormat)
                    {
                        XML xml = new XML(w, Console.Out, encoding, formatInfo);
                    }

                    w.close();
                }
            }
            catch (Exception t)
            {
                Console.WriteLine(t);
                Console.WriteLine(t.StackTrace);
            }
        }
Beispiel #2
0
        public static void Main(string[] Args)
        {
            if (Args.Length == 0)
                {
                displayHelp();
                return;
                }

            if (Args[0] == "-help" || Args[0] == "-h")
                {
                displayHelp();
                return;
                }

            if (Args[0] == "-version")
                {
                Console.WriteLine("v" + Workbook.getVersion());
                return;
                }

            bool write = false;
            bool readwrite = false;
            bool formulas = false;
            bool biffdump = false;
            bool jxlversion = false;
            bool propertysets = false;
            bool features = false;
            bool escher = false;
            bool escherdg = false;
            string file = Args[0];
            string outputFile = null;
            string propertySet = null;

            if (Args[0] == "-write")
                {
                write = true;
                file = Args[1];
                }
            else if (Args[0] == "-formulas")
                {
                formulas = true;
                file = Args[1];
                }
            else if (Args[0] == "-features")
                {
                features = true;
                file = Args[1];
                }
            else if (Args[0] == "-escher")
                {
                escher = true;
                file = Args[1];
                }
            else if (Args[0] == "-escherdg")
                {
                escherdg = true;
                file = Args[1];
                }
            else if (Args[0] == "-biffdump" || Args[0] == "-bd")
                {
                biffdump = true;
                file = Args[1];
                }
            else if (Args[0] == "-wa")
                {
                jxlversion = true;
                file = Args[1];
                }
            else if (Args[0] == "-ps")
                {
                propertysets = true;
                file = Args[1];

                if (Args.Length > 2)
                    propertySet = Args[2];

                if (Args.Length == 4)
                    outputFile = Args[3];
                }
            else if (Args[0] == "-readwrite" || Args[0] == "-rw")
                {
                readwrite = true;
                file = Args[1];
                outputFile = Args[2];
                }
            else
                {
                file = Args[Args.Length - 1];
                }

            string encoding = "UTF8";
            int format = CSVFormat;
            bool formatInfo = false;
            bool hideCells = false;

            if (write == false &&
                readwrite == false &&
                formulas == false &&
                biffdump == false &&
                jxlversion == false &&
                propertysets == false &&
                features == false &&
                escher == false &&
                escherdg == false)
                {
                for (int i = 0; i < Args.Length - 1; i++)
                    {
                    if (Args[i] == "-unicode")
                        encoding = "UnicodeBig";
                    else if (Args[i] == "-xml")
                        format = XMLFormat;
                    else if (Args[i] == "-csv")
                        format = CSVFormat;
                    else if (Args[i] == "-format")
                        formatInfo = true;
                    else if (Args[i] == "-hide")
                        hideCells = true;
                    else
                        {
                        Console.WriteLine("Command format:  CSV [-unicode] [-xml|-csv] excelfile");
                        return;
                        }
                    }
                }

            try
                {
                if (write)
                    {
                    Write w = new Write(file);
                    w.write();
                    }
                else if (readwrite)
                    {
                    ReadWrite rw = new ReadWrite(file, outputFile);
                    rw.readWrite();
                    }
                else if (formulas)
                    {
                    Workbook w = Workbook.getWorkbook(new FileInfo(file));
                    Formulas f = new Formulas(w, Console.Out, encoding);
                    w.close();
                    }
                else if (features)
                    {
                    Workbook w = Workbook.getWorkbook(new FileInfo(file));
                    Features f = new Features(w, Console.Out, encoding);
                    w.close();
                    }
                else if (escher)
                    {
                    Workbook w = Workbook.getWorkbook(new FileInfo(file));
                    Escher f = new Escher(w, Console.Out, encoding);
                    w.close();
                    }
                else if (escherdg)
                    {
                    Workbook w = Workbook.getWorkbook(new FileInfo(file));
                    EscherDrawingGroup f = new EscherDrawingGroup(w, Console.Out, encoding);
                    w.close();
                    }
                else if (biffdump)
                    {
                    BiffDump bd = new BiffDump(new FileInfo(file), Console.Out);
                    }
                else if (jxlversion)
                    {
                    WriteAccess bd = new WriteAccess(new FileInfo(file), Console.Out);
                    }
                else if (propertysets)
                    {
                    TextWriter os = Console.Out;
                    //if (outputFile != null)
                    //    os = new TextWriter((outputFile, FileMode.Create));
                    PropertySetsReader psr = new PropertySetsReader(new FileInfo(file), propertySet, os);
                    }
                else
                    {
                    Workbook w = Workbook.getWorkbook(new FileInfo(file));

                    //        findTest(w);

                    if (format == CSVFormat)
                        {
                        CSV csv = new CSV(w, Console.Out, encoding, hideCells);
                        }
                    else if (format == XMLFormat)
                        {
                        XML xml = new XML(w, Console.Out, encoding, formatInfo);
                        }

                    w.close();
                    }
                }
            catch (Exception t)
                {
                Console.WriteLine(t);
                Console.WriteLine(t.StackTrace);
                }
        }