public static void Run()
        {
            // ExStart:1
            // The path to the documents directory.
            string dataDir  = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
            string filePath = dataDir + "Book1.xlsx";

            // Create a Workbook object and opening the file from its path
            Workbook wb = new Workbook(filePath);

            // Instantiate Text File's Save Options
            TxtSaveOptions options = new TxtSaveOptions();

            // Set KeepSeparatorsForBlankRow to true show separators in blank rows
            options.KeepSeparatorsForBlankRow = true;

            // Save the file with the options
            wb.Save(dataDir + "output.csv", options);
            // ExEnd:1

            Console.WriteLine("KeepSeparatorsForBlankRow executed successfully.\r\n");
        }
Пример #2
0
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName);

            // Create project instance
            Project project1 = new Project(dataDir + "ConstraintAsLateAsPossible.mpp");

            // ExStart:SetConstraintAsLateAsPossible
            // Set constraint As Late As Possible for task with Id 11
            Task wallBoard = project1.RootTask.Children.GetById(11);

            wallBoard.Set(Tsk.ConstraintType, ConstraintType.AsLateAsPossible);

            // Save project as pdf
            SaveOptions options = new PdfSaveOptions();

            options.StartDate = project1.Get(Prj.StartDate);
            options.Timescale = Timescale.ThirdsOfMonths;
            project1.Save(dataDir + "project_AsLateAsPossible_out.pdf", options);
            // ExEnd:SetConstraintAsLateAsPossible
        }
        public static void Run()
        {
            //ExStart:ReadStopResumeDates
            // Read project from file stream
            string     dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName);
            FileStream fs      = new FileStream(dataDir + "StopResumeDates.mpp", FileMode.Open);
            Project    prj     = new Project(fs);

            fs.Close();

            // Create a ChildTasksCollector instance
            ChildTasksCollector collector = new ChildTasksCollector();

            // Collect all the tasks from RootTask using TaskUtils
            TaskUtils.Apply(prj.RootTask, collector, 0);

            // Check Stop and Resume dates for all tasks
            foreach (Task tsk1 in collector.Tasks)
            {
                if (tsk1.Get(Tsk.Stop).ToShortDateString() == "1/1/2000")
                {
                    Console.WriteLine("Stop: NA");
                }
                else
                {
                    Console.WriteLine("Stop: " + tsk1.Get(Tsk.Stop).ToShortDateString());
                }

                if (tsk1.Get(Tsk.Resume).ToShortDateString() == "1/1/2000")
                {
                    Console.WriteLine("Resume: NA");
                }
                else
                {
                    Console.WriteLine("Resume: " + tsk1.Get(Tsk.Resume).ToShortDateString());
                }
            }
            //ExEnd:ReadStopResumeDates
        }
Пример #4
0
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName);

            // ExStart:GetResourceCosts
            // Create project instance
            Project project1 = new Project(dataDir + "ResourceCosts.mpp");

            // Display all resources costs
            foreach (Resource res in project1.Resources)
            {
                if (res.Get(Rsc.Name) != null)
                {
                    Console.WriteLine(res.Get(Rsc.Cost));
                    Console.WriteLine(res.Get(Rsc.ACWP));
                    Console.WriteLine(res.Get(Rsc.BCWS));
                    Console.WriteLine(res.Get(Rsc.BCWP));
                }
            }
            // ExEnd:GetResourceCosts
        }
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName);

            // ExStart:PrintTaskWritingException
            try
            {
                Project project = new Project(dataDir + "PrintTaskWritingException.mpp");
                Console.Write("This example will only work if you apply a valid Aspose License. You can purchase full license or get 30 day temporary license from http://www.aspose.com/purchase/default.aspx.");
                project.Save(dataDir + "project_out.MPP", SaveFileFormat.MPP);
            }
            catch (TasksWritingException ex)
            {
                Console.WriteLine(ex.LogText);
            }
            catch (NotSupportedException ex)
            {
                Console.WriteLine(ex.Message + "\nThis example will only work if you apply a valid Aspose License. You can purchase full license or get 30 day temporary license from http://www.aspose.com/purchase/default.aspx.");
            }
            // ExEnd:PrintTaskWritingException
        }
        public static void Run()
        {
            // ExStart:1
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
            // Instantiate and open an Excel file
            Workbook book = new Workbook(dataDir + "book1.xlsx");

            // Define ImageOrPrintOptions
            ImageOrPrintOptions imgOptions = new ImageOrPrintOptions();

            // Specify the image format
            imgOptions.ImageFormat = System.Drawing.Imaging.ImageFormat.Jpeg;
            // Set the vertical and horizontal resolution
            imgOptions.VerticalResolution   = 200;
            imgOptions.HorizontalResolution = 200;
            // One page per sheet is enabled
            imgOptions.OnePagePerSheet = true;

            // Get the first worksheet
            Worksheet sheet = book.Worksheets[1];
            // Render the sheet with respect to specified image/print options
            SheetRender sr = new SheetRender(sheet, imgOptions);
            // Render the image for the sheet
            Bitmap bmp = sr.ToImage(0);
            // Create a bitmap
            Bitmap thumb = new Bitmap(100, 100);

            // Get the graphics for the bitmap
            System.Drawing.Graphics gr = System.Drawing.Graphics.FromImage(thumb);
            if (bmp != null)
            {
                // Draw the image
                gr.DrawImage(bmp, 0, 0, 100, 100);
            }
            // Save the thumbnail
            thumb.Save(dataDir + "mythumbnail.out.bmp");
            // ExEnd:1
        }
Пример #7
0
        public static void Run()
        {
            // ExStart:SettingPivotTableOption
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

            Workbook wb = new Workbook(dataDir + "input.xlsx");

            PivotTable pt = wb.Worksheets[0].PivotTables[0];

            // Indicating if or not display the empty cell value
            pt.DisplayNullString = true;

            // Indicating the null string
            pt.NullString = "null";
            pt.CalculateData();

            pt.RefreshDataOnOpeningFile = false;

            wb.Save(dataDir + "output_out_.xlsx");
            // ExEnd:SettingPivotTableOption
        }
Пример #8
0
        public static void Run()
        {
            try
            {
                string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName);

                //ExStart:LinkTasks
                Project project = new Project(dataDir + "SampleProject.mpp");

                Task task1 = project.RootTask.Children.GetById(1);
                Task task2 = project.RootTask.Children.GetById(2);
                Task task3 = project.RootTask.Children.GetById(3);
                Task task4 = project.RootTask.Children.GetById(4);
                Task task5 = project.RootTask.Children.GetById(5);

                // Link the tasks
                project.TaskLinks.Add(task1, task2, TaskLinkType.FinishToStart);
                project.TaskLinks.Add(task2, task3, TaskLinkType.FinishToStart);
                project.TaskLinks.Add(task3, task4, TaskLinkType.FinishToStart);
                project.TaskLinks.Add(task4, task5, TaskLinkType.FinishToStart);
                project.TaskLinks.Add(task2, task5, TaskLinkType.FinishToStart);

                // Display links among the tasks
                TaskLinkCollection links = project.TaskLinks;
                foreach (TaskLink link in links)
                {
                    Console.WriteLine("From ID = " + link.PredTask.Get(Tsk.Id) + "=>To ID = " + link.SuccTask.Get(Tsk.Id));
                    Console.WriteLine("________________________________________");
                }

                // Save the project
                project.Save(dataDir + "LinkTasks_out.mpp", SaveFileFormat.MPP);
                //ExEnd:LinkTasks
            }
            catch (NotSupportedException ex)
            {
                Console.WriteLine(ex.Message + "\nThis example will only work if you apply a valid Aspose License. You can purchase full license or get 30 day temporary license from http://www.aspose.com/purchase/default.aspx.");
            }
        }
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir  = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName);
            string fileName = "Project2.mpp";

            // ExStart:RenderGanttChartWithBarsNotRolledUp
            PdfSaveOptions options = new PdfSaveOptions();

            options.PresentationFormat = PresentationFormat.GanttChart;
            options.FitContent         = true;
            options.RollUpGanttBars    = false;
            options.DrawNonWorkingTime = false;
            options.PageSize           = PageSize.A3;

            string  file       = Path.Combine(dataDir, fileName);
            string  resultFile = Path.Combine(dataDir, "RenderGanttChartWithBarsNotRolledUp_out.pdf");
            Project project    = new Project(file);

            project.Save(resultFile, (SaveOptions)options);
            // ExEnd:RenderGanttChartWithBarsNotRolledUp
        }
Пример #10
0
        public static void Run()
        {
            // ExStart:1
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

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

            // Obtaining the reference of the PageSetup of the worksheet
            Aspose.Cells.PageSetup pageSetup = workbook.Worksheets[0].PageSetup;

            // Defining column numbers A & B as title columns
            pageSetup.PrintTitleColumns = "$A:$B";

            // Defining row numbers 1 & 2 as title rows
            pageSetup.PrintTitleRows = "$1:$2";

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

            // Load your sample workbook which contains embedded PowerPoint ole object
            Workbook wb = new Workbook(dataDir + "sample.xls");

            // Access its first worksheet
            Worksheet ws = wb.Worksheets[0];

            // Access first ole object inside the worksheet
            OleObject oleObj = ws.OleObjects[0];

            // Convert 16-bytes array into GUID
            Guid guid = new Guid(oleObj.ClassIdentifier);

            // Print the GUID
            Console.WriteLine(guid.ToString().ToUpper());
            // ExEnd:GetSetClassIdentifierEmbedOleObject
        }
Пример #12
0
        public static void Run()
        {
            try
            {
                // ExStart:1
                // The path to the documents directory.
                string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

                DateTime          start    = DateTime.Now;
                Excel.Application excelApp = new Application();
                string            myPath   = dataDir + @"TempBook.xls";
                excelApp.Workbooks.Open(myPath, Missing.Value, Missing.Value,
                                        Missing.Value, Missing.Value,
                                        Missing.Value, Missing.Value,
                                        Missing.Value, Missing.Value,
                                        Missing.Value, Missing.Value,
                                        Missing.Value, Missing.Value,
                                        Missing.Value, Missing.Value);

                for (int i = 1; i <= 1000; i++)
                {
                    for (int j = 1; j <= 20; j++)
                    {
                        excelApp.Cells[i, j] = "Row " + i.ToString() + " " + "Col " + j.ToString();
                    }
                }

                excelApp.Save(dataDir + @"TempBook1_out.xls");
                excelApp.Quit();
                DateTime end  = DateTime.Now;
                TimeSpan time = end - start;
                Console.WriteLine("File Created! " + "Time consumed (Seconds): " + time.TotalSeconds.ToString());
                // ExEnd:1
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
        public static void Run()
        {
            // ExStart:1
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
            // Define a new Workbook.
            Workbook workbook;

            // Load the workbook with the spcified worksheet only.
            LoadOptions loadOptions = new LoadOptions(LoadFormat.Xlsx);

            loadOptions.LoadFilter = new CustomLoad();

            // Creat the workbook.
            workbook = new Workbook(dataDir + "TestData.xlsx", loadOptions);

            // Perform your desired task.

            // Save the workbook.
            workbook.Save(dataDir + "outputFile.out.xlsx");
            // ExEnd:1
        }
        public static void Run()
        {
            //ExStart:SetGeneralResourceAssignmentProperties
            // Create empty project
            Project project1 = new Project();

            // Add new task and resource
            Task     task1 = project1.RootTask.Children.Add("Task");
            Resource rsc1  = project1.Resources.Add("Rsc");

            rsc1.Set(Rsc.StandardRate, 10);
            rsc1.Set(Rsc.OvertimeRate, 15);

            // Assign the resource desired task
            ResourceAssignment assn = project1.ResourceAssignments.Add(task1, rsc1);
            //ExEnd:SetGeneralResourceAssignmentProperties

            // Save project as PDF
            string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName);

            project1.Save(dataDir + "SetGeneralResourceAssignmentProperties_out.pdf", SaveFileFormat.PDF);
        }
Пример #15
0
        public static void Run()
        {
            // ExStart:GetRowHeightsOfSourceRangeToDestinationRange
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

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

            // Source worksheet
            Worksheet srcSheet = workbook.Worksheets[0];

            // Add destination worksheet
            Worksheet dstSheet = workbook.Worksheets.Add("Destination Sheet");

            // Set the row height of the 4th row. This row height will be copied to destination range
            srcSheet.Cells.SetRowHeight(3, 50);

            // Create source range to be copied
            Range srcRange = srcSheet.Cells.CreateRange("A1:D10");

            // Create destination range in destination worksheet
            Range dstRange = dstSheet.Cells.CreateRange("A1:D10");

            // PasteOptions, we want to copy row heights of source range to destination range
            PasteOptions opts = new PasteOptions();

            opts.PasteType = PasteType.RowHeights;

            // Copy source range to destination range with paste options
            dstRange.Copy(srcRange, opts);

            // Write informative message in cell D4 of destination worksheet
            dstSheet.Cells["D4"].PutValue("Row heights of source range copied to destination range");

            // Save the workbook in xlsx format
            workbook.Save(dataDir + "output_out.xlsx", SaveFormat.Xlsx);
            // ExEnd:GetRowHeightsOfSourceRangeToDestinationRange
        }
        public static void Run()
        {
            // ExStart:CalculateWidthAndHeightOfCellValueInUnitOfPixel
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

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

            // Access first worksheet
            Worksheet worksheet = workbook.Worksheets[0];

            // Access cell B2 and add some value inside it
            Cell cell = worksheet.Cells["B2"];

            cell.PutValue("Welcome to Aspose!");

            // Enlarge its font to size 16
            Style style = cell.GetStyle();

            style.Font.Size = 16;
            cell.SetStyle(style);

            // Calculate the width and height of the cell value in unit of pixels
            int widthOfValue  = cell.GetWidthOfValue();
            int heightOfValue = cell.GetHeightOfValue();

            // Print both values
            Console.WriteLine("Width of Cell Value: " + widthOfValue);
            Console.WriteLine("Height of Cell Value: " + heightOfValue);

            // Set the row height and column width to adjust/fit the cell value inside cell
            worksheet.Cells.SetColumnWidthPixel(1, widthOfValue);
            worksheet.Cells.SetRowHeightPixel(1, heightOfValue);

            // Save the output excel file
            workbook.Save(dataDir + "output_out.xlsx");
            // ExEnd:CalculateWidthAndHeightOfCellValueInUnitOfPixel
        }
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir  = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName);
            string fileName = "Project2.mpp";

            //ExStart:RenderGanttChartWithBarsRolledUp
            //ExFor: SaveOptions.RollUpGanttBars
            //ExSummary: Shows how to set a value indicating that subtasks on the summary task bar must be rolled up.
            PdfSaveOptions options = new PdfSaveOptions();

            options.PresentationFormat = PresentationFormat.GanttChart;
            options.FitContent         = true;
            options.RollUpGanttBars    = true;
            options.DrawNonWorkingTime = true;
            options.PageSize           = PageSize.A3;

            Project project = new Project(Path.Combine(dataDir, fileName));

            project.Save(Path.Combine(dataDir, "RenderGanttChartWithBarsRolledUp_out.pdf"), options);
            //ExEnd:RenderGanttChartWithBarsRolledUp
        }
Пример #18
0
        public static void Run()
        {
            string dataDir = RunExamples.GetDataDir();

            //ExStart: GetValueOfNullFeatureAttribute
            using (VectorLayer layer = VectorLayer.Open(dataDir + "InputShapeFile.shp", Drivers.Shapefile))
            {
                int index = 0;
                foreach (Feature feature in layer)
                {
                    DateTime?date = feature.GetValue <DateTime?>("dob");
                    Console.WriteLine("Feature #{0}", index);
                    Console.WriteLine("\tAttribute value present: {0}", date.HasValue);
                    if (date.HasValue)
                    {
                        Console.WriteLine("\tAttribute value: {0}", date.Value);
                    }
                    index++;
                }
            }
            //ExEnd: GetValueOfNullFeatureAttribute
        }
Пример #19
0
        public static void Run()
        {
            // ExStart:FindQueryTablesAndListObjectsOfExternalDataConnections
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

            // Load workbook object
            Workbook workbook = new Workbook(dataDir + "sample.xlsm");

            // Check all the connections inside the workbook
            for (int i = 0; i < workbook.DataConnections.Count; i++)
            {
                Aspose.Cells.ExternalConnections.ExternalConnection externalConnection = workbook.DataConnections[i];
                Console.WriteLine("connection: " + externalConnection.Name);
                PrintTables(workbook, externalConnection);
                Console.WriteLine();
            }

            Console.WriteLine("Press any key to continue...");
            Console.ReadKey();
            // ExEnd:FindQueryTablesAndListObjectsOfExternalDataConnections
        }
Пример #20
0
        public static void Run()
        {
            // ExStart:1
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

            // Instantiating a Workbook object
            Workbook  workbook = new Workbook();
            Worksheet sheet    = workbook.Worksheets[0];

            // Adds an empty conditional formatting
            int index = sheet.ConditionalFormattings.Add();
            FormatConditionCollection fcs = sheet.ConditionalFormattings[index];

            // Sets the conditional format range.
            CellArea ca = new CellArea();

            ca.StartRow    = 0;
            ca.EndRow      = 5;
            ca.StartColumn = 0;
            ca.EndColumn   = 3;
            fcs.AddArea(ca);

            // Adds condition.
            int conditionIndex = fcs.AddCondition(FormatConditionType.CellValue, OperatorType.Between, "50", "100");

            // Sets the background color.
            FormatCondition fc = fcs[conditionIndex];

            // fc.Style.BackgroundColor = Color.Red;

            fc.Style.Font.IsItalic    = true;
            fc.Style.Font.IsBold      = true;
            fc.Style.Font.IsStrikeout = true;
            fc.Style.Font.Underline   = FontUnderlineType.Double;
            fc.Style.Font.Color       = Color.Black;
            workbook.Save(dataDir + "output.xlsx");
            // ExEnd:1
        }
        public static void Run()
        {
            // ExStart:1
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

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

            // Accessing the first worksheet in the Excel file
            Worksheet worksheet = workbook.Worksheets[0];

            // Setting the number of pages to which the length of the worksheet will be spanned
            worksheet.PageSetup.FitToPagesTall = 1;

            // Setting the number of pages to which the width of the worksheet will be spanned
            worksheet.PageSetup.FitToPagesWide = 1;

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

            // Loads the workbook which contains hidden external links
            Workbook workbook = new Workbook(dataDir + "sample.xlsx");

            // Access the external link collection of the workbook
            ExternalLinkCollection links = workbook.Worksheets.ExternalLinks;

            // Print all the external links and check there IsVisible property
            for (int i = 0; i < links.Count; i++)
            {
                Console.WriteLine("Data Source: " + links[i].DataSource);
                Console.WriteLine("Is Referred: " + links[i].IsReferred);
                Console.WriteLine("Is Visible: " + links[i].IsVisible);
                Console.WriteLine();
            }
            // ExEnd:CheckHiddenExternalLinks
        }
        public static void Run()
        {
            // ExStart:1
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

            // Create workbook object from excel file
            Workbook wb = new Workbook(dataDir + "Book1.xlsm");

            // Please use System.Security.Cryptography.X509Certificates namespace for X509Certificate2 class
            X509Certificate2 cert = new X509Certificate2(dataDir + "SampleCert.pfx", "1234");

            // Create a Digital Signature
            DigitalSignature ds = new DigitalSignature(cert, "Signing Digital Signature using Aspose.Cells", DateTime.Now);

            // Sign VBA Code Project with Digital Signature
            wb.VbaProject.Sign(ds);

            // Save the workbook
            wb.Save(dataDir + "DigitallySigned_out_.xlsm");
            // ExEnd:1
        }
        public static void Run()
        {
            // ExStart:1
            // Create a scene
            Scene scene = new Scene();
            // Create cylinder 1
            var cylinder1 = new Cylinder(2, 2, 10, 20, 1, false);

            // Customized shear bottom for cylinder 1
            cylinder1.ShearBottom = new Vector2(0, 0.83);// shear 47.5deg in xy plane(z-axis)
            // Add cylinder 1 to the scene
            scene.RootNode.CreateChildNode(cylinder1).Transform.Translation = new Vector3(10, 0, 0);
            // Create cylinder 2
            var cylinder2 = new Cylinder(2, 2, 10, 20, 1, false);

            // Add cylinder to without a ShearBottom to the scene
            scene.RootNode.CreateChildNode(cylinder2);
            // Save scene
            scene.Save(RunExamples.GetDataDir() + "CustomizedShearBottomCylinder.obj", FileFormat.WavefrontOBJ);

            // ExEnd:1
        }
        public static void Run()
        {
            // ExStart:1
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

            // Open the template workbook
            Workbook workbook = new Workbook(dataDir + "CustomerReport.xlsx");

            // Accessing the first worksheet in the Excel file
            Worksheet worksheet = workbook.Worksheets[0];

            // Setting the orientation to Portrait
            worksheet.PageSetup.Orientation = PageOrientationType.Portrait;

            // Setting the scaling factor to 100
            // worksheet.PageSetup.Zoom = 100;

            // OR Alternately you can use Fit to Page Options as under

            // Setting the number of pages to which the length of the worksheet will be spanned
            worksheet.PageSetup.FitToPagesTall = 1;

            // Setting the number of pages to which the width of the worksheet will be spanned
            worksheet.PageSetup.FitToPagesWide = 1;

            // Setting the paper size to A4
            worksheet.PageSetup.PaperSize = PaperSizeType.PaperA4;

            // Setting the print quality of the worksheet to 1200 dpi
            worksheet.PageSetup.PrintQuality = 1200;

            //Setting the first page number of the worksheet pages
            worksheet.PageSetup.FirstPageNumber = 2;

            // Save the workbook
            workbook.Save(dataDir + "PageSetup_out_.xlsx");
            // ExEnd:1
        }
        public static void Run()
        {
            // ExStart:1
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

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

            // Insert a value into the A1 cell in the first worksheet
            workbook.Worksheets[0].Cells[0, 0].PutValue("Testing PDF/A");

            // Define PdfSaveOptions
            PdfSaveOptions pdfSaveOptions = new PdfSaveOptions();

            // Set the compliance type
            pdfSaveOptions.Compliance = PdfCompliance.PdfA1b;

            // Save the file
            workbook.Save(dataDir + "output.pdf", pdfSaveOptions);
            // ExEnd:1
        }
Пример #27
0
        public static void Run()
        {
            // ExStart:1
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

            // Open the template file.
            Workbook workbook = new Workbook(dataDir + "source.xlsx");

            // Access first worksheet.
            Worksheet worksheet = workbook.Worksheets[0];

            // Access first list object or table.
            ListObject lstObj = worksheet.ListObjects[0];

            // Set the comment of the list object
            lstObj.Comment = "This is Aspose.Cells comment.";

            // Save the workbook in xlsx format
            workbook.Save(dataDir + "SetCommentOfTableOrListObject_out.xlsx", SaveFormat.Xlsx);
            // ExEnd:1
        }
        public static void Run()
        {
            // ExStart:WriteDefaultProperties
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName);

            // Create a project instance and Set default properties
            Project project = new Project();

            project.Set(Prj.ScheduleFromStart, true);
            project.Set(Prj.StartDate, DateTime.Now);
            project.Set(Prj.DefaultStartTime, project.Get(Prj.StartDate));
            project.Set(Prj.DefaultTaskType, TaskType.FixedDuration);
            project.Set(Prj.DefaultStandardRate, 15);
            project.Set(Prj.DefaultOvertimeRate, 12);
            project.Set(Prj.DefaultTaskEVMethod, EarnedValueMethodType.PercentComplete);
            project.Set(Prj.DefaultFixedCostAccrual, CostAccrualType.Prorated);

            // Save the project to XML format
            project.Save(dataDir + "WriteDefaultProperties_out.xml", SaveFileFormat.XML);
            // ExEnd:WriteDefaultProperties
        }
Пример #29
0
        public static void Run()
        {
            // ExStart:CalculateArrayFormula
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

            // Create workbook from source excel file
            Workbook workbook = new Workbook(dataDir + "DataTable.xlsx");

            // Access first worksheet
            Worksheet worksheet = workbook.Worksheets[0];

            // When you will put 100 in B1, then all Data Table values formatted as Yellow will become 120
            worksheet.Cells["B1"].PutValue(100);

            // Calculate formula, now it also calculates Data Table array formula
            workbook.CalculateFormula();

            // Save the workbook in pdf format
            workbook.Save(dataDir + "output_out_.pdf");
            // ExEnd:CalculateArrayFormula
        }
Пример #30
0
        public static void Run()
        {
            // ExStart:1
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

            // Open the template file.
            Workbook workbook = new Workbook(dataDir + "Sample.xlsx");

            // Access the first worksheet
            Worksheet sheet = workbook.Worksheets[0];

            // Access the first chart inside the sheet
            Chart chart = sheet.Charts[0];

            // Set text of second legend entry fill to none
            chart.Legend.LegendEntries[1].IsTextNoFill = true;

            // Save the workbook in xlsx format
            workbook.Save(dataDir + "ChartLegendEntry_out.xlsx", SaveFormat.Xlsx);
            // ExEnd:1
        }