Пример #1
0
        static void Main(string[] args)
        {
            //Instantiating a Workbook object
            Workbook workbook = new Workbook();

            //Adding a new worksheet to the Workbook object
            WorksheetCollection worksheets = workbook.Worksheets;
            Worksheet           worksheet  = worksheets.Add("My Worksheet");

            //Obtaining the reference of the PageSetup of the worksheet
            PageSetup pageSetup = worksheet.PageSetup;

            //Setting worksheet name at the left  header
            pageSetup.SetHeader(0, "&A");

            //Setting current date and current time at the central header
            //and changing the font of the header
            pageSetup.SetHeader(1, "&\"Times New Roman,Bold\"&D-&T");

            //Setting current file name at the right header and changing the font of the header
            pageSetup.SetHeader(2, "&\"Times New Roman,Bold\"&12&F");

            //Setting a string at the left footer and changing the font of the footer
            pageSetup.SetFooter(0, "Hello World! &\"Courier New\"&14 123");

            //Setting picture at the central footer
            pageSetup.SetFooter(1, "&G");

            workbook.Save("../../data/headerfooter.xlsx");
        }
Пример #2
0
        public static void Run()
        {
            // Create an instance of Workbook
            Workbook book = new Workbook();

            // Get the WorksheetCollection
            WorksheetCollection worksheets = book.Worksheets;

            // Add a new Named Range with name "data"
            int index = worksheets.Names.Add("data");

            // Access the newly created Named Range from the collection
            Name data = worksheets.Names[index];

            // Set RefersTo property of the Named Range to a cell range in same worksheet
            data.RefersTo = "=Sheet1!$A$1:$A$10";

            // Add another Named Range with name "range"
            index = worksheets.Names.Add("range");

            // Access the newly created Named Range from the collection
            Name range = worksheets.Names[index];

            // Set RefersTo property to a formula using the Named Range data
            range.RefersTo = "=INDEX(data,Sheet1!$A$1,1):INDEX(data,Sheet1!$A$1,9)";

            // Save the workbook
            book.Save(outputDir + "outputSettingComplexFormulaOfRange.xlsx");

            Console.WriteLine("SettingComplexFormulaOfRange executed successfully.");
        }
        public static void Run()
        {
            // ExStart:SettingSimpleFormulaForNamedRanges
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

            // Create an instance of Workbook
            Workbook book = new Workbook();

            // Get the WorksheetCollection
            WorksheetCollection worksheets = book.Worksheets;

            // Add a new Named Range with name "NewNamedRange"
            int index = worksheets.Names.Add("NewNamedRange");

            // Access the newly created Named Range
            Name name = worksheets.Names[index];

            // Set RefersTo property of the Named Range to a formula. Formula references another cell in the same worksheet
            name.RefersTo = "=Sheet1!$A$3";

            // Set the formula in the cell A1 to the newly created Named Range
            worksheets[0].Cells["A1"].Formula = "NewNamedRange";

            // Insert the value in cell A3 which is being referenced in the Named Range
            worksheets[0].Cells["A3"].PutValue("This is the value of A3");

            // Calculate formulas
            book.CalculateFormula();

            // Save the result in XLSX format
            book.Save(dataDir + "output_out.xlsx");
            // ExEnd:SettingSimpleFormulaForNamedRanges
        }
Пример #4
0
        private void GenerarHoja(WorksheetCollection sheets, string NombHoja, DataTable rtRedumen)
        {
            switch (NombHoja)
            {
            case "Table":
                NombHoja = "PRODUCTO PRECIO MAXIMO";
                break;

            case "Table1":
                NombHoja = "PRODUCTO PRECIO MINIMO";
                break;
            }
            Worksheet sheet = sheets.Add(NombHoja);

            sheet.Table.DefaultRowHeight   = 15;
            sheet.Table.DefaultColumnWidth = 66;
            sheet.Table.FullColumns        = 1;
            sheet.Table.FullRows           = 1;
            sheet.Table.StyleID            = "s62";
            sheet.Table.Columns.Add(50);
            sheet.Table.Columns.Add(65);
            sheet.Table.Columns.Add(250);
            sheet.Table.Columns.Add(100);
            sheet.Table.Columns.Add(100);
            sheet.Table.Columns.Add(100);
            sheet.Table.Columns.Add(100);
            sheet.Table.Columns.Add(100);
            sheet.Table.Columns.Add(100);
            sheet.Table.Columns.Add(100);
            sheet.Table.Columns.Add(100);
            GenerarEncabezadoDatosEnHoja(sheet);
            GenerarDatosEnHoja(sheet, rtRedumen);
        }
Пример #5
0
        public static DataSet ExeclToDataSet(string Path)
        {
            try
            {
                DataTable dt = new DataTable();
                //Aspose.Cells.Workbook workbook = new Workbook();
                //workbook.Open(Path);

                Aspose.Cells.Workbook workbook = new Workbook(Path);
                WorksheetCollection   wsts     = workbook.Worksheets;

                for (int i = 0; i < wsts.Count; i++)
                {
                    Worksheet wst  = wsts[i];
                    int       MaxR = wst.Cells.MaxRow;
                    int       MaxC = wst.Cells.MaxColumn;
                    if (MaxR > 0 && MaxC > 0)
                    {
                        dt = wst.Cells.ExportDataTableAsString(0, 0, MaxR + 1, MaxC + 1, true);
                    }
                }

                //SqlDataAdapter adapter = null;
                DataSet ds = new DataSet();
                ds.Tables.Add(dt);
                //adapter.Fill(dt);
                return(ds);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Пример #6
0
        public static void Run()
        {
            // ExStart:1
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

            // Create a workbook object
            Workbook workbook = new Workbook();

            // Get the worksheets in the workbook
            WorksheetCollection worksheets = workbook.Worksheets;

            // Get the first (default) worksheet
            Worksheet worksheet = worksheets[0];

            // Get the pagesetup object
            PageSetup pageSetup = worksheet.PageSetup;

            // Set bottom,left,right and top page margins
            pageSetup.BottomMargin = 2;
            pageSetup.LeftMargin   = 1;
            pageSetup.RightMargin  = 1;
            pageSetup.TopMargin    = 3;

            // Save the Workbook.
            workbook.Save(dataDir + "SetMargins_out.xls");
            // ExEnd:1
        }
 public void SetUp()
 {
     using(var book = Workbook.Open(@"TestData\Book1.xlsx"))
     {
         tested = book.Sheets;
     }
 }
Пример #8
0
        static void Main(string[] args)
        {
            //Instantiating a Workbook object
            Workbook workbook = new Workbook();

            //Adding a new worksheet to the Workbook object
            WorksheetCollection worksheets = workbook.Worksheets;
            Worksheet           worksheet  = worksheets.Add("My Worksheet");

            //Insert a string value to a cell
            worksheet.Cells["C2"].Value = "Image";

            //Set the 4th row height
            worksheet.Cells.SetRowHeight(3, 150);

            //Set the C column width
            worksheet.Cells.SetColumnWidth(2, 50);

            //Add a picture to the C4 cell
            int index = worksheet.Pictures.Add(3, 2, 3, 2, "../../data/aspose.png");

            //Get the picture object
            //Picture pic = worksheet.getPictures().get(index);
            Picture pic = worksheet.Pictures[index];

            //Set the placement type
            pic.Placement = PlacementType.FreeFloating;

            workbook.Save("../../data/image.xlsx");
        }
Пример #9
0
        public static void Run()
        {
            // Create an instance of Workbook
            Workbook book = new Workbook();

            // Get the WorksheetCollection
            WorksheetCollection worksheets = book.Worksheets;

            // Add a new Named Range with name "NewNamedRange"
            int index = worksheets.Names.Add("NewNamedRange");

            // Access the newly created Named Range
            Name name = worksheets.Names[index];

            // Set RefersTo property of the Named Range to a formula. Formula references another cell in the same worksheet
            name.RefersTo = "=Sheet1!$A$3";

            // Set the formula in the cell A1 to the newly created Named Range
            worksheets[0].Cells["A1"].Formula = "NewNamedRange";

            // Insert the value in cell A3 which is being referenced in the Named Range
            worksheets[0].Cells["A3"].PutValue("This is the value of A3");

            // Calculate formulas
            book.CalculateFormula();

            // Save the result in XLSX format
            book.Save(outputDir + "outputSettingSimpleFormulaWithRange.xlsx");

            Console.WriteLine("SettingSimpleFormulaWithRange executed successfully.");
        }
Пример #10
0
        public static void Run()
        {
            // Create an instance of Workbook
            Workbook book = new Workbook();

            // Get the WorksheetCollection
            WorksheetCollection worksheets = book.Worksheets;

            // Insert some data in cell A1 of Sheet1
            worksheets["Sheet1"].Cells["A1"].PutValue(10);

            // Add a new Worksheet and insert a value to cell A1
            worksheets[worksheets.Add()].Cells["A1"].PutValue(10);

            // Add a new Named Range with name "range"
            int index = worksheets.Names.Add("range");

            // Access the newly created Named Range from the collection
            Name range = worksheets.Names[index];

            // Set RefersTo property of the Named Range to a SUM function
            range.RefersTo = "=SUM(Sheet1!$A$1,Sheet2!$A$1)";

            // Insert the Named Range as formula to 3rd worksheet
            worksheets[worksheets.Add()].Cells["A1"].Formula = "range";

            // Calculate formulas
            book.CalculateFormula();

            // Save the result in XLSX format
            book.Save(outputDir + "outputCalculatingSumUsingNamedRange.xlsx");

            Console.WriteLine("CalculatingSumUsingNamedRange executed successfully.");
        }
Пример #11
0
 public Workbook()
 {
     _sharedStrings = new SharedStrings();
     _cells         = new CellRepo();
     _styles        = new StyleFactory(_cells);
     _sheets        = new WorksheetCollection(_sharedStrings, _cells);
 }
Пример #12
0
        public static void HeaderAndFooterMargins()
        {
            // ExStart:HeaderAndFooterMargins
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

            // Create a workbook object
            Workbook workbook = new Workbook();

            // Get the worksheets in the workbook
            WorksheetCollection worksheets = workbook.Worksheets;

            // Get the first (default) worksheet
            Worksheet worksheet = worksheets[0];

            // Get the pagesetup object
            PageSetup pageSetup = worksheet.PageSetup;

            // Specify Header / Footer margins
            pageSetup.HeaderMargin = 2;
            pageSetup.FooterMargin = 2;

            // Save the Workbook.
            workbook.Save(dataDir + "CenterOnPage_out.xls");
            // ExEnd:HeaderAndFooterMargins
        }
Пример #13
0
        public static void Run()
        {
            // ExStart:1
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

            string InputPath = dataDir + "book1.xls";

            // Open an existing excel file.
            Workbook wb = new Workbook(InputPath);

            // Create a Worksheets object with reference to
            // the sheets of the Workbook.
            WorksheetCollection sheets = wb.Worksheets;

            // Get the first worksheet.
            Worksheet worksheet = sheets[0];

            // Move the first sheet to the third position in the workbook.
            worksheet.MoveTo(2);

            // Save the excel file.
            wb.Save(dataDir + "MoveWorksheet_out.xls");
            // ExEnd:1
        }
        public static void Run()
        {
            // ExStart:SettingComplexFormulaNamedRange
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

            // Create an instance of Workbook
            Workbook book = new Workbook();

            // Get the WorksheetCollection
            WorksheetCollection worksheets = book.Worksheets;

            // Add a new Named Range with name "data"
            int index = worksheets.Names.Add("data");

            // Access the newly created Named Range from the collection
            Name data = worksheets.Names[index];

            // Set RefersTo property of the Named Range to a cell range in same worksheet
            data.RefersTo = "=Sheet1!$A$1:$A$10";

            // Add another Named Range with name "range"
            index = worksheets.Names.Add("range");

            // Access the newly created Named Range from the collection
            Name range = worksheets.Names[index];

            // Set RefersTo property to a formula using the Named Range data
            range.RefersTo = "=INDEX(data,Sheet1!$A$1,1):INDEX(data,Sheet1!$A$1,9)";

            // Save the workbook
            book.Save(dataDir + "output_out_.xlsx");
            // ExEnd:SettingComplexFormulaNamedRange
        }
Пример #15
0
        public static DataTable ExeclToDataTable(string Path)
        {
            try
            {
                DataTable             dt       = new DataTable();
                Aspose.Cells.Workbook workbook = new Workbook(Path);
                //workbook.Open(Path); //已过时
                //Worksheets wsts = workbook.Worksheets;  //已过时


                //Worksheet sheet = workbook.Worksheets["New Worksheet1"];
                WorksheetCollection wsts = workbook.Worksheets;


                for (int i = 0; i < wsts.Count; i++)
                {
                    Worksheet wst  = wsts[i];
                    int       MaxR = wst.Cells.MaxRow;
                    int       MaxC = wst.Cells.MaxColumn;
                    if (MaxR > 0 && MaxC > 0)
                    {
                        dt = wst.Cells.ExportDataTableAsString(0, 0, MaxR + 1, MaxC + 1, true);
                    }
                }
                return(dt);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
        public static void Run()
        {
            //Source directory
            string sourceDir = RunExamples.Get_SourceDirectory();

            //Output directory
            string outputDir = RunExamples.Get_OutputDirectory();

            // Open an existing excel file.
            Workbook wb = new Workbook(sourceDir + "sampleDeletingBlankRows.xlsx");

            // Create a Worksheets object with reference to
            // The sheets of the Workbook.
            WorksheetCollection sheets = wb.Worksheets;

            // Get first Worksheet from WorksheetCollection
            Worksheet sheet = sheets[0];

            // Delete the Blank Rows from the worksheet
            sheet.Cells.DeleteBlankRows();

            // Save the excel file.
            wb.Save(outputDir + "outputDeletingBlankRows.xlsx");

            Console.WriteLine("DeletingBlankRows executed successfully.");
        }
Пример #17
0
        public static void CenterOnPage()
        {
            // ExStart:CenterOnPage
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

            // Create a workbook object
            Workbook workbook = new Workbook();

            // Get the worksheets in the workbook
            WorksheetCollection worksheets = workbook.Worksheets;

            // Get the first (default) worksheet
            Worksheet worksheet = worksheets[0];

            // Get the pagesetup object
            PageSetup pageSetup = worksheet.PageSetup;

            // Specify Center on page Horizontally and Vertically
            pageSetup.CenterHorizontally = true;
            pageSetup.CenterVertically   = true;

            // Save the Workbook.
            workbook.Save(dataDir + "CenterOnPage_out.xls");
            // ExEnd:CenterOnPage
        }
Пример #18
0
        private void RunStyleChanger()
        {
            string filePath = Path.GetDirectoryName(XLSpath);
            string fileName = Path.GetFileNameWithoutExtension(XLSpath);
            string tmpFile  = Path.Combine(filePath, "backup_" + fileName + Path.GetExtension(XLSpath));

            File.Copy(XLSpath, tmpFile);

            Workbook            wb  = new Workbook(XLSpath);
            WorksheetCollection wsc = wb.Worksheets;
            int i          = 1;
            int noOfSheets = wsc.Count;

            for (int wsIndex = 0; wsIndex < noOfSheets; wsIndex++)
            {
                try
                {
                    Worksheet ws = wb.Worksheets[wsIndex];
                    StyleChanger(ref ws);
                    i++;
                    Program.mainWindow.updateProgress(Convert.ToInt32(100.0 * Convert.ToDouble(i) / Convert.ToDouble(noOfSheets)));
                }
                catch (Exception ex)
                {
                    Log.AddLog("Error while converting sheet " + wsIndex.ToString() + " - " + ex.Message, true);
                }
            }

            wb.Save(XLSpath);
            Log.AddLog("Styles changed in " + XLSpath);
        }
Пример #19
0
        private void RunSplitterHide()
        {
            Workbook            wb  = new Workbook(XLSpath);
            WorksheetCollection wsc = wb.Worksheets;
            string filePath         = Path.GetDirectoryName(XLSpath);
            string fileName         = Path.GetFileNameWithoutExtension(XLSpath);
            int    i                = 1;
            int    noOfSheets       = wsc.Count;
            int    noOfSheetsDigits = noOfSheets.ToString().Length;

            foreach (Worksheet ws in wsc)
            {
                int    wsIndex     = ws.Index;
                string newFileName = "Sheet_" + SeqNumber(i, noOfSheetsDigits) + "_" + fileName + "_" + ws.Name + ".xlsx";
                string newFilePath = Path.Combine(filePath, newFileName);
                File.Copy(XLSpath, newFilePath);
                Workbook newWB = new Workbook(newFilePath);
                foreach (Worksheet wsInNewFile in newWB.Worksheets)
                {
                    if (wsInNewFile.Index != wsIndex)
                    {
                        wsInNewFile.IsVisible = false;
                    }
                }

                newWB.Save(newFilePath, SaveFormat.Xlsx);
                i++;
                Program.mainWindow.updateProgress(Convert.ToInt32(100.0 * Convert.ToDouble(i) / Convert.ToDouble(noOfSheets)));
            }
        }
Пример #20
0
        static void Main(string[] args)
        {
            // Instantiating a Workbook object
            Workbook workbook = new Workbook();

            // Obtaining the reference of the first worksheet
            WorksheetCollection worksheets = workbook.Worksheets;
            Worksheet           sheet      = worksheets[0];

            // Adding some sample value to cells
            Cells cells = sheet.Cells;
            Cell  cell  = cells["A1"];

            cell.Value = 50;
            cell       = cells["A2"];
            cell.Value = 100;
            cell       = cells["A3"];
            cell.Value = 150;
            cell       = cells["B1"];
            cell.Value = 4;
            cell       = cells["B2"];
            cell.Value = 20;
            cell       = cells["B3"];
            cell.Value = 50;

            ChartCollection charts = sheet.Charts;

            // Adding a chart to the worksheet
            int   chartIndex = charts.Add(ChartType.Pyramid, 5, 0, 15, 5);
            Chart chart      = charts[chartIndex];

            //Save the chart image file.
            chart.ToImage("AsposeChartImage.png", ImageFormat.Png);
        }
Пример #21
0
 private void GenerarHojas(WorksheetCollection sheets, DataSet data)
 {
     for (int i = 0; i < data.Tables.Count; i++)
     {
         DataTable rtRedumen = data.Tables[i];
         GenerarHoja(sheets, data.Tables[i].TableName, rtRedumen);
     }
 }
        public static void Run()
        {
            // ExStart:1
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

            // Create directory if it is not already present.
            bool IsExists = System.IO.Directory.Exists(dataDir);

            if (!IsExists)
            {
                System.IO.Directory.CreateDirectory(dataDir);
            }

            // Instantiate a new Workbook.
            Workbook workbook = new Workbook();

            // Get all the worksheets in the book.
            WorksheetCollection worksheets = workbook.Worksheets;

            // Get the first worksheet in the worksheets collection.
            Worksheet worksheet = workbook.Worksheets[0];

            // Create a range of cells.
            Range range1 = worksheet.Cells.CreateRange("E12", "I12");

            // Name the range.
            range1.Name = "MyRange";

            // Set the outline border to the range.
            range1.SetOutlineBorder(BorderType.TopBorder, CellBorderType.Medium, Color.FromArgb(0, 0, 128));
            range1.SetOutlineBorder(BorderType.BottomBorder, CellBorderType.Medium, Color.FromArgb(0, 0, 128));
            range1.SetOutlineBorder(BorderType.LeftBorder, CellBorderType.Medium, Color.FromArgb(0, 0, 128));
            range1.SetOutlineBorder(BorderType.RightBorder, CellBorderType.Medium, Color.FromArgb(0, 0, 128));

            // Input some data with some formattings into
            // A few cells in the range.
            range1[0, 0].PutValue("Test");
            range1[0, 4].PutValue("123");


            // Create another range of cells.
            Range range2 = worksheet.Cells.CreateRange("B3", "F3");

            // Name the range.
            range2.Name = "testrange";

            // Copy the first range into second range.
            range2.Copy(range1);

            // Remove the previous named range (range1) with its contents.
            worksheet.Cells.ClearRange(11, 4, 11, 8);
            worksheets.Names.RemoveAt(0);

            // Save the excel file.
            workbook.Save(dataDir + "copyranges.out.xls");
            // ExEnd:1
        }
Пример #23
0
        public IList <ExcelColumn> ProcessSchemaSd(WorksheetCollection worksheets)
        {
            var sheet = worksheets.Where(p => p.Name == "sd").FirstOrDefault();
            var cells = sheet.Cells;

            var result = ProcessSD(cells);

            return(result);
        }
Пример #24
0
        private void RunJoinerHide()
        {
            string filePath  = Path.GetDirectoryName(XLSpath);
            string fileName  = Path.GetFileNameWithoutExtension(XLSpath);
            string tmpWBName = "MERGED_" + fileName + ".xlsx";
            string tmpWBPath = Path.Combine(filePath, tmpWBName);

            File.Copy(XLSpath, tmpWBPath);

            Workbook            wb  = new Workbook(tmpWBPath);
            WorksheetCollection wsc = wb.Worksheets;

            int i                 = 1;
            int noOfSheets        = wsc.Count;
            int noOfInvalidSheets = 0;
            int noOfSheetsDigits  = noOfSheets.ToString().Length;

            foreach (Worksheet ws in wsc)
            {
                string newFileName = "Sheet_" + SeqNumber(i, noOfSheetsDigits) + "_" + fileName + "_" + ws.Name + ".xlsx";
                string newFilePath = Path.Combine(filePath, newFileName);

                if (File.Exists(newFilePath))
                {
                    try
                    {
                        Workbook            wbToMerge  = new Workbook(newFilePath);
                        WorksheetCollection wscToMerge = wbToMerge.Worksheets;
                        Worksheet           wsToMerge  = wscToMerge[ws.Index];

                        CopyOptions co = new CopyOptions();
                        co.CopyInvalidFormulasAsValues = false;
                        co.ReferToSheetWithSameName    = true;
                        co.ReferToDestinationSheet     = true;
                        ws.Copy(wsToMerge, co);
                    }
                    catch
                    {
                        noOfInvalidSheets++;
                    }
                }
                else
                {
                    Log.AddLog("File not found: " + newFilePath, true);
                    noOfInvalidSheets++;
                }
                i++;
                Program.mainWindow.updateProgress(Convert.ToInt32(100 * Convert.ToDouble(i) / Convert.ToDouble(noOfSheets)));
            }

            wb.Save(tmpWBPath, SaveFormat.Xlsx);
            if (noOfInvalidSheets > 0)
            {
                throw new Exception("There are " + noOfInvalidSheets.ToString() + " invalid sheets.");
            }
        }
        public void WorksheetCollection_CreateNew()
        {
            // Arrange

            // Act
            var list = new WorksheetCollection();

            // Assert
            Assert.IsNotNull(list);
        }
Пример #26
0
        static void Main(string[] args)
        {
            //Create a new Workbook by excel file path
            Workbook wb = new Workbook("../../data/workbook.xlsx");

            //Create a Worksheets object with reference to the sheets of the Workbook.
            WorksheetCollection sheets = wb.Worksheets;

            //Copy data to a new sheet from an existing sheet within the Workbook.
            sheets.AddCopy("Sheet1");
            wb.Save("../../data/workbook.xlsx");
        }
Пример #27
0
        /// <summary>
        /// Workbook
        /// </summary>
        public Workbook()
        {
            Styles = new StyleCollection();

            Properties = new DocumentProperties();

            DocumentSettings = new DocumentSettings();

            ExcelWorkbook = new ExcelWorkbook();

            WorkSheets = new WorksheetCollection();
        }
Пример #28
0
        static void Main(string[] args)
        {
            //Instantiating a Workbook object
            Workbook workbook = new Workbook();

            //Adding a new worksheet to the Workbook object
            WorksheetCollection worksheets = workbook.Worksheets;
            Worksheet           worksheet  = worksheets.Add("My Worksheet");

            //Saving the Excel file
            workbook.Save("newWorksheet.xls");
        }
Пример #29
0
        /// <summary>
        /// Workbook
        /// </summary>
        public Workbook()
        {
            Styles = new StyleCollection();

            Properties = new DocumentProperties();

            DocumentSettings = new DocumentSettings();

            ExcelWorkbook = new ExcelWorkbook();

            WorkSheets = new WorksheetCollection();
        }
Пример #30
0
        private void RunPDFSaver()
        {
            string filePath = Path.GetDirectoryName(XLSpath);
            string fileName = Path.GetFileNameWithoutExtension(XLSpath);
            string tmpFile  = Path.Combine(filePath, "tmp_" + fileName + Path.GetExtension(XLSpath));

            File.Copy(XLSpath, tmpFile);

            Workbook            wb  = new Workbook(tmpFile);
            WorksheetCollection wsc = wb.Worksheets;
            int i                = 1;
            int noOfSheets       = wsc.Count;
            int noOfSheetsDigits = noOfSheets.ToString().Length;

            for (int wsIndex = 1; wsIndex < noOfSheets; wsIndex++)
            {
                wb.Worksheets[wsIndex].IsVisible = false;
            }

            for (int wsIndex = 0; wsIndex < noOfSheets; wsIndex++)
            {
                try
                {
                    Worksheet ws = wb.Worksheets[wsIndex];
                    StyleChanger(ref ws);

                    string         newFileName = ws.Name + "_" + fileName + ".pdf";
                    string         newFilePath = Path.Combine(filePath, newFileName);
                    PdfSaveOptions pso         = new PdfSaveOptions();
                    pso.OnePagePerSheet  = true;
                    pso.CalculateFormula = true;
                    wb.Save(newFilePath, pso);

                    if (wsIndex < noOfSheets - 1)
                    {
                        wb.Worksheets[wsIndex + 1].IsVisible = true;
                        wb.Worksheets[wsIndex].IsVisible     = false;
                    }

                    i++;
                    Program.mainWindow.updateProgress(Convert.ToInt32(100.0 * Convert.ToDouble(i) / Convert.ToDouble(noOfSheets)));
                }
                catch (Exception ex)
                {
                    Log.AddLog("Error while converting sheet " + wsIndex.ToString() + " - " + ex.Message, true);
                }
            }

            //wb.Save(tmpFile);

            File.Delete(tmpFile);
        }
        private void load_optimal()
        {
            lblOptimal.Text = "OPTIMAL";
            GRBVar[] allVar = MyGlobals.model.GetVars();
            spreadsheetControl1.Visible = true;

            //EXCEL WORKBOOK DOCUMENT FORMATION
            Excel.Application xlApp = new
                                      Microsoft.Office.Interop.Excel.Application();
            Excel.Workbook  xlWorkBook;
            Excel.Worksheet xlWorkSheet;
            object          misValue = System.Reflection.Missing.Value;

            xlWorkBook              = xlApp.Workbooks.Add(misValue);
            xlWorkSheet             = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);
            xlWorkSheet.Cells[1, 1] = "Variables";
            xlWorkSheet.Cells[1, 2] = "Value";

            xlWorkSheet.Cells[1, 4] = "Objective Value";
            xlWorkSheet.Cells[2, 4] = MyGlobals.model.Get(GRB.DoubleAttr.ObjVal);

            for (int k = 0; k < allVar.Length; k++)
            {
                xlWorkSheet.Cells[k + 2, 1] = allVar[k].Get(GRB.StringAttr.VarName);
                xlWorkSheet.Cells[k + 2, 2] = allVar[k].Get(GRB.DoubleAttr.X);
            }


            xlWorkBook.SaveAs("d:\\solutiondraft.xls", Excel.XlFileFormat.xlWorkbookNormal, misValue, misValue, misValue, misValue, Excel.XlSaveAsAccessMode.xlExclusive, misValue, misValue, misValue, misValue, misValue);
            xlWorkBook.Close(true, misValue, misValue);
            xlApp.Quit();

            releaseObject(xlWorkSheet);
            releaseObject(xlWorkBook);
            releaseObject(xlApp);

            //LOADING DOCUMENT
            spreadsheetControl1.LoadDocument("d:\\solutiondraft.xls");
            workbook   = spreadsheetControl1.Document;
            worksheets = workbook.Worksheets;
            worksheet  = workbook.Worksheets["Sheet1"];

            // Enable filtering for the specified cell range.
            Range range = worksheet["A1:E100"];

            worksheet.AutoFilter.Apply(range);

            btn_Excel.Enabled   = true;
            btn_HTML.Enabled    = true;
            btn_PDF.Enabled     = true;
            btn_SaveSol.Enabled = true;
        }
Пример #32
0
        public void UseIndexers()
        {
            #region radspreadsheet-model-working-with-worksheets-iterate-through-worksheets_0
            Workbook workbook = new Workbook();

            WorksheetCollection worksheets = workbook.Worksheets;
            worksheets.Add();
            worksheets.Add();

            Worksheet firstWorksheet  = worksheets[0];
            Worksheet secondWorksheet = worksheets["Sheet2"];
            #endregion
        }
Пример #33
0
        /// <summary>
        /// Formatiere das Dokument
        /// </summary>
        /// <param name="sheets"></param>
        private void GenerateWorksheetAbhackeListe(WorksheetCollection sheets) {
            Worksheet sheet = sheets.Add(this._SheetName + "   vom   " + DateTime.Now.ToLongDateString());
            this._Sheet = sheet;
            sheet.Table.StyleID = "ta1";
            WorksheetColumn column0 = sheet.Table.Columns.Add(58);
            WorksheetColumn column1 = sheet.Table.Columns.Add(60);
            WorksheetColumn column2 = sheet.Table.Columns.Add(48);
            WorksheetColumn column3 = sheet.Table.Columns.Add();
            column3.Width = 120;
            WorksheetColumn column44 = sheet.Table.Columns.Add();
            column44.Width = 80;
            WorksheetColumn column4 = sheet.Table.Columns.Add();
            column4.Width = 64;
            WorksheetColumn column7 = sheet.Table.Columns.Add();
            column7.Width = 20;
            WorksheetColumn column8 = sheet.Table.Columns.Add();
            column8.Width = 20;
            WorksheetColumn column9 = sheet.Table.Columns.Add();
            column9.Width = 20;
            WorksheetColumn column10 = sheet.Table.Columns.Add();
            column10.Width = 20;
            WorksheetColumn column11 = sheet.Table.Columns.Add();
            column11.Width = 20;
            WorksheetColumn column12 = sheet.Table.Columns.Add();
            column12.Width = 20;
            WorksheetColumn column13 = sheet.Table.Columns.Add();
            column13.Width = 170;  

            // Generierung Daten Zellen
            WorksheetRow Row0 = sheet.Table.Rows.Add();
            Row0.Height = 18;
            Row0.AutoFitHeight = true;
            WorksheetCell cell;
           
            cell = Row0.Cells.Add();
            cell.StyleID = "ce1";
            cell.Data.Type = DataType.String;
            cell.Data.Text = "Ausweis Nummer";
            cell.MergeDown = 1;
            
            cell = Row0.Cells.Add();
            cell.StyleID = "ce1";
            cell.Data.Type = DataType.String;
            cell.Data.Text = "Personen Haushalt";
            cell.MergeDown = 1;

            cell = Row0.Cells.Add();
            cell.StyleID = "ce1";
            cell.Data.Type = DataType.String;
            cell.Data.Text = "Gruppe";
            cell.MergeDown = 1;
            
            cell = Row0.Cells.Add();
            cell.StyleID = "ce1";
            cell.Data.Type = DataType.String;
            cell.Data.Text = "Name";
            cell.MergeDown = 1;
            
            cell = Row0.Cells.Add();
            cell.StyleID = "ce1";
            cell.Data.Type = DataType.String;
            cell.Data.Text = "Ort";
            cell.MergeDown = 1;
            
            cell = Row0.Cells.Add();
            cell.StyleID = "ce6";
            cell.Data.Type = DataType.String;
            cell.Data.Text = "Ausweis gültig bis";
            cell.MergeDown = 1;
            
            cell = Row0.Cells.Add();
            cell.StyleID = "ce8";
            cell.Data.Type = DataType.String;
            cell.Data.Text = "Wochen";
            cell.MergeAcross = 5;
            
            cell = Row0.Cells.Add();
            cell.StyleID = "ce9";
            cell.Data.Type = DataType.String;
            cell.Data.Text = "Bemerkungen";
            cell.MergeDown = 1;
            cell = Row0.Cells.Add();
            cell.Index = 1024;
            
            // -----------------------------------------------
           
            WorksheetRow Row1 = sheet.Table.Rows.Add();
            Row1.Height = 12;
            Row1.AutoFitHeight = false;
            // Hole Kalenderwochen, für die nächsten 6 Wochen aus Klasse: CalendarWeekDays, und
            // schreibe diese in das DataSheet
            for (int rows = 1; rows <= 6; rows++)
            {
                Row1.Cells.Add();
            }
            CalendarWeekDays cal = new CalendarWeekDays();
            List<int> weekList = new List<int>();
            weekList = cal.NumberOfWeek(DateTime.Now);
            for (int week = 0; week <= 5; week++)
            {
                Row1.Cells.Add(weekList[week].ToString(), DataType.Number, "ce10");
            }
            cell.Index = 1016;
            // -----------------------------------------------
            //  Optionen
            // -----------------------------------------------
            sheet.Options.ProtectObjects = false;
            sheet.Options.ProtectScenarios = false;
        }
Пример #34
0
        private void Load(CompoundFile doc)
        {
            Stream stream;
            try
            {
                // see if workbook works
                stream = doc.OpenStream("Workbook");
            }
            catch (IOException)
            {
                // see if book works, if not then leak the exception
                stream = doc.OpenStream("Book");
            }

            SstRecord sst = null;
            /* long sstPos = 0; */

            // record position dictionary
            SortedList<long, Biff> records = new SortedList<long, Biff>();

            _styles = new StyleCollection(this);
            _formats = new FormatCollection(this);
            _fonts = new FontCollection(this);
            _palette = new Palette(this);
            _hyperLinks = new HyperLinkCollection(this);

            while (stream.Length - stream.Position >= GenericBiff.MinimumSize)
            {
                // capture the current stream position
                long pos = stream.Position;

                // decode the record if possible
                Biff record = GetCorrectRecord(new GenericBiff(stream), stream, sst);

                // capture 
                // shared string table 
                if (record is SstRecord)
                {
                    Debug.Assert(sst == null);
                    sst = (SstRecord)record;
                    /* sstPos = pos; */
                }
                // formatting records
                else if (record is FormatRecord)
                {
                    FormatRecord f = (FormatRecord)record;
                    _formats.Add(f.Index, new Format(this, f));
                }
                else if (record is FontRecord)
                    _fonts.Add(new Font(this, (FontRecord)record));
                else if (record is PaletteRecord)
                    _palette.Initialize((PaletteRecord)record);
                else if (record is XfRecord)
                    _styles.Add(new Style(this, (XfRecord)record));
                else if (record is HyperLinkRecord)
                    _hyperLinks.Add((HyperLinkRecord)record);

                Debug.Assert(!records.ContainsKey(pos));
                // store the position and corresponding record
                records[pos] = record;
            }

            // generate the worksheets
            _sheets = new WorksheetCollection();
            foreach (Biff record in records.Values)
            {
                if (record is BoundSheetRecord)
                    _sheets.Add(new Worksheet(this, (BoundSheetRecord)record, records));
            }
        }
Пример #35
0
        private void GenerateShopListWorksheet(WorksheetCollection sheets)
        {
            Worksheet sheet = sheets.Add("ShopList");
            sheet.Names.Add(new WorksheetNamedRange("Print_Area", "=Sheet1!R1C1:R24C6", false));
            sheet.Table.DefaultRowHeight = 14.25F;
            sheet.Table.DefaultColumnWidth = 54F;
            //sheet.Table.ExpandedColumnCount = 6;
            //sheet.Table.ExpandedRowCount = 24;
            sheet.Table.FullColumns = 1;
            sheet.Table.FullRows = 1;
            WorksheetColumn column0 = sheet.Table.Columns.Add();
            column0.Index = 5;
            column0.Width = 177;

            GenerateHeaders(sheet);

            GenerateDataRows(sheet);
            // -----------------------------------------------
            GenerateFooterRow(sheet);
            // -----------------------------------------------
            //  Options
            // -----------------------------------------------
            sheet.Options.Selected = true;
            sheet.Options.ProtectObjects = false;
            sheet.Options.ProtectScenarios = false;
            sheet.Options.PageSetup.Header.Margin = 0.3F;
            sheet.Options.PageSetup.Footer.Margin = 0.3F;
            sheet.Options.PageSetup.PageMargins.Bottom = 0.75F;
            sheet.Options.PageSetup.PageMargins.Left = 0.7F;
            sheet.Options.PageSetup.PageMargins.Right = 0.7F;
            sheet.Options.PageSetup.PageMargins.Top = 0.75F;
            sheet.Options.Print.PaperSizeIndex = 9;
            sheet.Options.Print.HorizontalResolution = 1200;
            sheet.Options.Print.VerticalResolution = 1200;
            sheet.Options.Print.ValidPrinterInfo = true;
        }
Пример #36
0
        private void GenerateWorksheetSheet1(WorksheetCollection sheets, Order order)
        {
            Culture.InitializeCulture();
            Worksheet sheet = sheets.Add(Resource.Admin_ViewOrder_ItemNum + order.OrderID);
            sheet.Table.DefaultRowHeight = 15F;
            sheet.Table.ExpandedColumnCount = 5;
            List<TaxValue> taxedItems = TaxServices.GetOrderTaxes(order.OrderID);
            sheet.Table.ExpandedRowCount = 42 + order.OrderItems.Count * 2 + taxedItems.Count;
            sheet.Table.FullColumns = 1;
            sheet.Table.FullRows = 1;
            WorksheetColumn column0 = sheet.Table.Columns.Add();
            column0.Width = 186;
            column0.Span = 1;
            WorksheetColumn column1 = sheet.Table.Columns.Add();
            column1.Index = 3;
            column1.Width = 156;
            sheet.Table.Columns.Add(120);
            sheet.Table.Columns.Add(89);
            // Order ID-----------------------------------------------
            WorksheetRow Row0 = sheet.Table.Rows.Add();
            Row0.Height = 22;
            WorksheetCell cell;
            cell = Row0.Cells.Add();
            cell.StyleID = "s132";
            cell.Data.Type = DataType.String;
            cell.Data.Text = Resource.Admin_ViewOrder_ItemNum + order.OrderID;
            cell.MergeAcross = 4;
            // Status -----------------------------------------------
            WorksheetRow Row1 = sheet.Table.Rows.Add();
            cell = Row1.Cells.Add();
            cell.StyleID = "s133";
            cell.Data.Type = DataType.String;
            cell.Data.Text = "(" + order.OrderStatus.StatusName + ")";
            cell.MergeAcross = 4;
            //  -----------------------------------------------
            WorksheetRow Row2 = sheet.Table.Rows.Add();
            cell = Row2.Cells.Add();
            cell.StyleID = "s134";
            cell.MergeAcross = 4;
            // Date -----------------------------------------------
            WorksheetRow Row3 = sheet.Table.Rows.Add();
            cell = Row3.Cells.Add();
            cell.StyleID = "s135";
            cell.Data.Type = DataType.String;
            cell.Data.Text = Resource.Admin_ViewOrder_Date;
            cell = Row3.Cells.Add();
            cell.StyleID = "s70";
            cell.Data.Type = DataType.String;
            cell.Data.Text = Culture.ConvertDate(order.OrderDate);
            cell.MergeAcross = 3;
            // NUmber to status check -----------------------------------------------
            WorksheetRow Row4 = sheet.Table.Rows.Add();
            cell = Row4.Cells.Add();
            cell.StyleID = "s135";
            cell.Data.Type = DataType.String;
            cell.Data.Text = Resource.Admin_ViewOrder_Number;
            cell = Row4.Cells.Add();
            cell.StyleID = "s70";
            cell.Data.Type = DataType.String;
            cell.Data.Text = order.Number;
            cell.MergeAcross = 3;
            // Status comment -----------------------------------------------
            WorksheetRow Row5 = sheet.Table.Rows.Add();
            cell = Row5.Cells.Add();
            cell.StyleID = "s135";
            cell.Data.Type = DataType.String;
            cell.Data.Text = Resource.Admin_ViewOrder_StatusComment;
            cell = Row5.Cells.Add();
            cell.StyleID = "s70";
            cell.Data.Type = DataType.String;
            cell.Data.Text = order.StatusComment;
            cell.MergeAcross = 3;

            WorksheetRow RowEmail = sheet.Table.Rows.Add();
            cell = RowEmail.Cells.Add();
            cell.StyleID = "s135";
            cell.Data.Type = DataType.String;
            cell.Data.Text = Resource.Admin_ViewCustomer_Email;
            cell = RowEmail.Cells.Add();
            cell.StyleID = "s70";
            cell.Data.Type = DataType.String;
            cell.Data.Text = order.OrderCustomer.Email;
            cell.MergeAcross = 3;

            WorksheetRow RowPhone = sheet.Table.Rows.Add();
            cell = RowPhone.Cells.Add();
            cell.StyleID = "s135";
            cell.Data.Type = DataType.String;
            cell.Data.Text = Resource.Admin_CommonSettings_Phone;
            cell = RowPhone.Cells.Add();
            cell.StyleID = "s70";
            cell.Data.Type = DataType.String;
            cell.Data.Text = order.OrderCustomer.MobilePhone;
            cell.MergeAcross = 3;

            // -----------------------------------------------
            WorksheetRow Row6 = sheet.Table.Rows.Add();
            cell = Row6.Cells.Add();
            cell.StyleID = "s136";
            cell.MergeAcross = 4;
            // Headers -----------------------------------------------
            WorksheetRow Row7 = sheet.Table.Rows.Add();
            Row7.Cells.Add(Resource.Admin_ViewOrder_Billing, DataType.String, "s70");
            Row7.Cells.Add(Resource.Admin_ViewOrder_Shipping, DataType.String, "s70");
            Row7.Cells.Add(Resource.Admin_ViewOrder_ShippingMethod, DataType.String, "s70");
            // Names -----------------------------------------------
            WorksheetRow Row8 = sheet.Table.Rows.Add();
            Row8.Cells.Add("���� " + Resource.Admin_ViewOrder_Name + order.BillingContact.Name, DataType.String, "s70");

            Row8.Cells.Add("���� " + Resource.Admin_ViewOrder_Name + order.ShippingContact.Name, DataType.String, "s70");
            var shippingMethodName = order.ArchivedShippingName;
            if (order.OrderPickPoint != null)
                shippingMethodName += order.OrderPickPoint.PickPointAddress.Replace("<br/>", " ");

            Row8.Cells.Add("���� " + shippingMethodName, DataType.String, "s70");
            // Countries -----------------------------------------------
            WorksheetRow Row9 = sheet.Table.Rows.Add();
            Row9.Cells.Add("�����" + Resource.Admin_ViewOrder_Country + order.BillingContact.Country, DataType.String,
                           "s70");
            Row9.Cells.Add("�����" + Resource.Admin_ViewOrder_Country + order.ShippingContact.Country, DataType.String,
                           "s70");
            Row9.Cells.Add(Resource.Admin_ViewOrder_PaymentType, DataType.String, "s70");
            // Cities -----------------------------------------------
            WorksheetRow Row10 = sheet.Table.Rows.Add();
            Row10.Cells.Add("�����" + Resource.Admin_ViewOrder_City + order.BillingContact.City, DataType.String, "s70");
            Row10.Cells.Add("�����" + Resource.Admin_ViewOrder_City + order.ShippingContact.City, DataType.String, "s70");
            Row10.Cells.Add("���� " + order.PaymentMethodName, DataType.String, "s70");
            // Zones -----------------------------------------------
            WorksheetRow Row11 = sheet.Table.Rows.Add();
            Row11.Cells.Add("�����" + Resource.Admin_ViewOrder_Zone + order.BillingContact.Zone, DataType.String, "s70");
            Row11.Cells.Add("�����" + Resource.Admin_ViewOrder_Zone + order.ShippingContact.Zone, DataType.String, "s70");
            cell = Row11.Cells.Add();
            cell.StyleID = "s70";
            // Zips -----------------------------------------------
            WorksheetRow Row12 = sheet.Table.Rows.Add();
            Row12.Cells.Add("�����" + Resource.Admin_ViewOrder_Zip + order.BillingContact.Zip, DataType.String, "s70");
            Row12.Cells.Add("�����" + Resource.Admin_ViewOrder_Zip + order.ShippingContact.Zip, DataType.String, "s70");
            cell = Row12.Cells.Add();
            cell.StyleID = "s70";
            // Adresses -----------------------------------------------
            WorksheetRow Row13 = sheet.Table.Rows.Add();
            Row13.Cells.Add("�����" + Resource.Admin_ViewOrder_Address + order.BillingContact.Address, DataType.String,
                            "s70");
            Row13.Cells.Add("�����" + Resource.Admin_ViewOrder_Address + order.ShippingContact.Address, DataType.String,
                            "s70");
            cell = Row13.Cells.Add();
            cell.StyleID = "s70";
            // -----------------------------------------------
            WorksheetRow Row17 = sheet.Table.Rows.Add();
            cell = Row17.Cells.Add();
            cell.StyleID = "s134";
            cell.MergeAcross = 4;
            // Orders -----------------------------------------------
            WorksheetRow Row18 = sheet.Table.Rows.Add();
            cell = Row18.Cells.Add();
            cell.StyleID = "s136";
            cell.Data.Type = DataType.String;
            cell.Data.Text = Resource.Admin_ViewOrder_OrderItem;
            cell.MergeAcross = 4;
            // -----------------------------------------------
            WorksheetRow Row19 = sheet.Table.Rows.Add();
            Row19.Height = 15;
            cell = Row19.Cells.Add();
            cell.StyleID = "s137";
            cell.MergeAcross = 4;
            // Order items table header -----------------------------------------------
            WorksheetRow Row20 = sheet.Table.Rows.Add();
            Row20.Height = 16;
            Row20.Cells.Add(Resource.Admin_ViewOrder_ItemName, DataType.String, "s89");
            Row20.Cells.Add(Resource.Admin_ViewOrder_CustomOptions, DataType.String, "s90");
            Row20.Cells.Add(Resource.Admin_ViewOrder_Price, DataType.String, "s90");
            Row20.Cells.Add(Resource.Admin_ViewOrder_ItemAmount, DataType.String, "s90");
            Row20.Cells.Add(Resource.Admin_ViewOrder_ItemCost, DataType.String, "s91");
            // Order items -----------------------------------------------
            foreach (OrderItem item in order.OrderItems)
            {
                WorksheetRow Row = sheet.Table.Rows.Add();
                cell = Row.Cells.Add();
                cell.StyleID = "m51494176";
                cell.Data.Type = DataType.String;
                cell.Data.Text = item.ArtNo + ", " + item.Name;
                cell.MergeDown = 1;
                cell = Row.Cells.Add();
                cell.StyleID = "m51494196";
                var html = new StringBuilder();

                if (!string.IsNullOrEmpty(item.Color))
                    html.Append(Configuration.SettingsCatalog.ColorsHeader + ": " + item.Color + " \n");

                if (!string.IsNullOrEmpty(item.Size))
                    html.Append(Configuration.SettingsCatalog.SizesHeader + ": " + item.Size + " \n");

                foreach (EvaluatedCustomOptions ev in item.SelectedOptions)
                {
                    html.Append(string.Format("- {0}: {1} \n", ev.CustomOptionTitle, ev.OptionTitle));
                }

                cell.Data.Text = html.ToString();
                cell.MergeDown = 1;
                cell = Row.Cells.Add();
                cell.StyleID = "m51494216";
                cell.Data.Type = DataType.String;

                cell.Data.Text = CatalogService.GetStringPrice(item.Price, order.OrderCurrency.CurrencyValue,
                                                               order.OrderCurrency.CurrencyCode);
                cell.MergeDown = 1;
                cell = Row.Cells.Add();
                cell.StyleID = "m51494236";
                cell.Data.Type = DataType.String;
                cell.Data.Text = item.Amount.ToString();
                cell.MergeDown = 1;
                cell = Row.Cells.Add();
                cell.StyleID = "m51494256";
                cell.Data.Type = DataType.String;

                cell.Data.Text = CatalogService.GetStringPrice(item.Price * item.Amount,
                                                               order.OrderCurrency.CurrencyValue,
                                                               order.OrderCurrency.CurrencyCode);
                cell.MergeDown = 1;
                // -----------------------------------------------
                WorksheetRow RowSep = sheet.Table.Rows.Add();
                RowSep.Height = 15;
            }
            // -----------------------------------------------
            WorksheetRow Row27 = sheet.Table.Rows.Add();
            Row27.Height = 15;
            cell = Row27.Cells.Add();
            cell.StyleID = "s70";
            cell = Row27.Cells.Add();
            cell.StyleID = "s70";
            cell.Data.Type = DataType.String;
            cell.Data.Text = Resource.Admin_ViewOrder_ItemCost2;
            cell.Index = 4;

            var ordCurrency = order.OrderCurrency;
            float productPrice = order.OrderItems.Sum(item => item.Amount * item.Price);

            Row27.Cells.Add(
                CatalogService.GetStringPrice(productPrice, ordCurrency.CurrencyValue, ordCurrency.CurrencyCode),
                DataType.String, "s70");
            // -----------------------------------------------
            float totalDiscount = order.OrderDiscount;
            if (totalDiscount > 0)
            {
                WorksheetRow Row28 = sheet.Table.Rows.Add();
                cell = Row28.Cells.Add();
                cell.StyleID = "s70";
                cell = Row28.Cells.Add();
                cell.StyleID = "s70";
                cell.Data.Type = DataType.String;
                cell.Data.Text = Resource.Admin_ViewOrder_ItemDiscount;
                cell.Index = 4;

                Row28.Cells.Add(
                    "-" +
                    CatalogService.GetStringDiscountPercent(productPrice, totalDiscount,
                                                            ordCurrency.CurrencyValue, ordCurrency.CurrencySymbol,
                                                            ordCurrency.IsCodeBefore,
                                                            CurrencyService.CurrentCurrency.PriceFormat, false),
                    DataType.String, "s70");
            }
            // -----------------------------------------------
            WorksheetRow Row29 = sheet.Table.Rows.Add();
            cell = Row29.Cells.Add();
            cell.StyleID = "s70";
            cell = Row29.Cells.Add();
            cell.StyleID = "s70";
            cell.Data.Type = DataType.String;
            cell.Data.Text = Resource.Admin_ViewOrder_ShippingPrice;
            cell.Index = 4;

            Row29.Cells.Add(
                "+" +
                CatalogService.GetStringPrice(order.ShippingCost, order.OrderCurrency.CurrencyValue,
                                              order.OrderCurrency.CurrencyCode), DataType.String, "s70");

            if (order.PaymentCost > 0)
            {
                WorksheetRow Row291 = sheet.Table.Rows.Add();
                cell = Row291.Cells.Add();
                cell.StyleID = "s70";
                cell = Row291.Cells.Add();
                cell.StyleID = "s70";
                cell.Data.Type = DataType.String;
                cell.Data.Text = Resource.Admin_ViewOrder_PaymentExtracharge;
                cell.Index = 4;

                Row291.Cells.Add(
                    "+" +
                    CatalogService.GetStringPrice(order.PaymentCost, order.OrderCurrency.CurrencyValue,
                                                  order.OrderCurrency.CurrencyCode), DataType.String, "s70");
            }

            // -----------------------------------------------

            if (taxedItems.Count > 0)
                foreach (TaxValue tax in taxedItems)
                {
                    WorksheetRow Row = sheet.Table.Rows.Add();
                    cell = Row.Cells.Add();
                    cell.StyleID = "s70";
                    cell = Row.Cells.Add();
                    cell.StyleID = "s70";
                    cell.Data.Type = DataType.String;
                    cell.Data.Text = (tax.TaxShowInPrice ? Resource.Core_TaxServices_Include_Tax + " " : "") +
                                     tax.TaxName + ":";
                    cell.Index = 4;
                    Row.Cells.Add(
                        (tax.TaxShowInPrice ? "" : "+") +
                        CatalogService.GetStringPrice(tax.TaxSum, order.OrderCurrency.CurrencyValue,
                                                      order.OrderCurrency.CurrencyCode), DataType.String, "s70");
                }
            else
            {
                WorksheetRow Row30a = sheet.Table.Rows.Add();
                cell = Row30a.Cells.Add();
                cell.StyleID = "s70";
                cell = Row30a.Cells.Add();
                cell.StyleID = "s70";
                cell.Data.Type = DataType.String;
                cell.Data.Text = Resource.Admin_ViewOrder_Taxes;
                cell.Index = 4;

                Row30a.Cells.Add(
                    "+" +
                    CatalogService.GetStringPrice(0, order.OrderCurrency.CurrencyValue, order.OrderCurrency.CurrencyCode),
                    DataType.String, "s70");
            }
            // -----------------------------------------------
            WorksheetRow Row30 = sheet.Table.Rows.Add();
            cell = Row30.Cells.Add();
            cell.StyleID = "s70";
            cell = Row30.Cells.Add();
            cell.StyleID = "s135";
            cell.Data.Type = DataType.String;
            cell.Data.Text = Resource.Admin_ViewOrder_TotalPrice;
            cell.Index = 4;

            cell =
                Row30.Cells.Add(
                    CatalogService.GetStringPrice(order.Sum, order.OrderCurrency.CurrencyValue,
                                                  order.OrderCurrency.CurrencyCode), DataType.String, "s135");

            // -----------------------------------------------
            WorksheetRow Row31 = sheet.Table.Rows.Add();
            cell = Row31.Cells.Add();
            cell.StyleID = "s135";
            cell.Data.Type = DataType.String;
            cell.Data.Text = Resource.Client_PrintOrder_YourComment;
            cell.MergeAcross = 4;
            // -----------------------------------------------
            WorksheetRow Row32 = sheet.Table.Rows.Add();
            cell = Row32.Cells.Add();
            cell.StyleID = "s141";
            cell.Data.Type = DataType.String;
            cell.Data.Text = order.CustomerComment;
            cell.MergeAcross = 4;
            cell.MergeDown = 1;
            // -----------------------------------------------
            //  Options
            // -----------------------------------------------
            sheet.Options.Selected = true;
            sheet.Options.ProtectObjects = false;
            sheet.Options.ProtectScenarios = false;
            sheet.Options.PageSetup.Header.Margin = 0.3F;
            sheet.Options.PageSetup.Footer.Margin = 0.3F;
            sheet.Options.PageSetup.PageMargins.Bottom = 0.75F;
            sheet.Options.PageSetup.PageMargins.Left = 0.7F;
            sheet.Options.PageSetup.PageMargins.Right = 0.7F;
            sheet.Options.PageSetup.PageMargins.Top = 0.75F;
            sheet.Options.Print.PaperSizeIndex = 9;
            sheet.Options.Print.VerticalResolution = 0;
            sheet.Options.Print.ValidPrinterInfo = true;
        }