Last active
April 12, 2021 03:21
-
-
Save aspose-com-gists/922f990b02cf4e04a328bd6f37029af8 to your computer and use it in GitHub Desktop.
This Gist contains code snippets from examples of Aspose.Cells for .NET.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| This Gist contains code snippets from examples of Aspose.Cells for .NET. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Workbook workbook = new Workbook("SourceExcel.xls"); | |
| workbook.Save("outputExcel.xlsx", SaveFormat.Xlsx); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| //Output directory | |
| static string outputDir = RunExamples.Get_OutputDirectory(); | |
| //Create InterruptMonitor object | |
| InterruptMonitor im = new InterruptMonitor(); | |
| //This function will create workbook and convert it to Pdf format | |
| void CreateWorkbookAndConvertItToPdfFormat() | |
| { | |
| //Create a workbook object | |
| Workbook wb = new Workbook(); | |
| //Assign it InterruptMonitor object | |
| wb.InterruptMonitor = im; | |
| //Access first worksheet | |
| Worksheet ws = wb.Worksheets[0]; | |
| //Access cell J1000000 and add some text inside it. | |
| Cell cell = ws.Cells["J1000000"]; | |
| cell.PutValue("This is text."); | |
| try | |
| { | |
| //Save the workbook to Pdf format | |
| wb.Save(outputDir + "output_InterruptMonitor.pdf"); | |
| } | |
| catch (Aspose.Cells.CellsException ex) | |
| { | |
| Console.WriteLine("Process Interrupted - Message: " + ex.Message); | |
| } | |
| } | |
| //This function will interrupt the conversion process after 10s | |
| void WaitForWhileAndThenInterrupt() | |
| { | |
| Thread.Sleep(1000 * 10); | |
| im.Interrupt(); | |
| } | |
| public void TestRun() | |
| { | |
| ThreadStart ts1 = new ThreadStart(this.CreateWorkbookAndConvertItToPdfFormat); | |
| Thread t1 = new Thread(ts1); | |
| t1.Start(); | |
| ThreadStart ts2 = new ThreadStart(this.WaitForWhileAndThenInterrupt); | |
| Thread t2 = new Thread(ts2); | |
| t2.Start(); | |
| t1.Join(); | |
| t2.Join(); | |
| } | |
| public static void Run() | |
| { | |
| new StopConversionOrLoadingUsingInterruptMonitor().TestRun(); | |
| Console.WriteLine("StopConversionOrLoadingUsingInterruptMonitor executed successfully."); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Create empty workbook. | |
| Workbook wb = new Workbook(); | |
| // Some data in the form of byte array. | |
| // Please use correct XML and Schema instead. | |
| byte[] btsData = new byte[] { 1, 2, 3 }; | |
| byte[] btsSchema = new byte[] { 1, 2, 3 }; | |
| // Create four custom xml parts. | |
| wb.CustomXmlParts.Add(btsData, btsSchema); | |
| wb.CustomXmlParts.Add(btsData, btsSchema); | |
| wb.CustomXmlParts.Add(btsData, btsSchema); | |
| wb.CustomXmlParts.Add(btsData, btsSchema); | |
| // Assign ids to custom xml parts. | |
| wb.CustomXmlParts[0].ID = "Fruit"; | |
| wb.CustomXmlParts[1].ID = "Color"; | |
| wb.CustomXmlParts[2].ID = "Sport"; | |
| wb.CustomXmlParts[3].ID = "Shape"; | |
| // Specify search custom xml part id. | |
| String srchID = "Fruit"; | |
| srchID = "Color"; | |
| srchID = "Sport"; | |
| // Search custom xml part by the search id. | |
| Aspose.Cells.Markup.CustomXmlPart cxp = wb.CustomXmlParts.SelectByID(srchID); | |
| // Print the found or not found message on console. | |
| if (cxp == null) | |
| { | |
| Console.WriteLine("Not Found: CustomXmlPart ID " + srchID); | |
| } | |
| else | |
| { | |
| Console.WriteLine("Found: CustomXmlPart ID " + srchID); | |
| } | |
| Console.WriteLine("AddCustomXMLPartsAndSelectThemByID executed successfully."); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // The path to the documents directory. | |
| string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | |
| // Instantiating a Workbook object | |
| Workbook wb = new Workbook(); | |
| PictureCollection pics = wb.Worksheets[0].Pictures; | |
| pics.Add(10, 0,12,1,(Stream)null); | |
| SignatureLine signatureLine = new SignatureLine(); | |
| signatureLine.Id = Guid.NewGuid(); | |
| signatureLine.ProviderId = Guid.Empty; | |
| signatureLine.Signer = "Aspose.Cells"; | |
| signatureLine.Title = "signed by Aspose.Cells"; | |
| wb.Worksheets[0].Pictures[0].SignatureLine = signatureLine; | |
| X509Certificate2 certificate = new X509Certificate2(dataDir + "rsa2048.pfx", "123456"); | |
| Aspose.Cells.DigitalSignatures.DigitalSignature signature = | |
| new Aspose.Cells.DigitalSignatures.DigitalSignature(certificate, "test Microsoft Office signature line", DateTime.UtcNow); | |
| signature.Id = signatureLine.Id; | |
| signature.ProviderId = signatureLine.ProviderId; | |
| Aspose.Cells.DigitalSignatures.DigitalSignatureCollection dsCollection = new Aspose.Cells.DigitalSignatures.DigitalSignatureCollection(); | |
| dsCollection.Add(signature); | |
| wb.SetDigitalSignature(dsCollection); | |
| wb.Save(dataDir + "signatureLine.xlsx"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| //Output directory | |
| string outputDir = RunExamples.Get_OutputDirectory(); | |
| // Instantiate a new Workbook | |
| Workbook workbook = new Workbook(); | |
| // Get the first worksheet | |
| Worksheet worksheet = workbook.Worksheets[0]; | |
| //Add some text in cell A1 | |
| worksheet.Cells["A1"].PutValue("Here"); | |
| // Add a comment to A1 cell | |
| var comment = worksheet.Comments[worksheet.Comments.Add("A1")]; | |
| // Set its vertical alignment setting | |
| comment.CommentShape.TextVerticalAlignment = TextAlignmentType.Center; | |
| // Set the Comment note | |
| comment.Note = "This is my Comment Text. This is Test."; | |
| Shape shape = worksheet.Comments["A1"].CommentShape; | |
| shape.Fill.SolidFill.Color = Color.Black; | |
| Font font = shape.Font; | |
| font.Color = Color.White; | |
| StyleFlag styleFlag = new StyleFlag(); | |
| styleFlag.FontColor = true; | |
| shape.TextBody.Format(0, shape.Text.Length, font, styleFlag); | |
| // Save the Excel file | |
| workbook.Save(outputDir + "outputChangeCommentFontColor.xlsx"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| //Source directory | |
| string sourceDir = RunExamples.Get_SourceDirectory(); | |
| //Output directory | |
| string outputDir = RunExamples.Get_OutputDirectory(); | |
| // Load your excel file inside a workbook obect | |
| Workbook wb = new Workbook(sourceDir + "sampleChangeTextBoxOrShapeCharacterSpacing.xlsx"); | |
| // Access your text box which is also a shape object from shapes collection | |
| Shape shape = wb.Worksheets[0].Shapes[0]; | |
| // Access the first font setting object via GetCharacters() method | |
| FontSetting fs = (FontSetting)shape.GetCharacters()[0]; | |
| //Set the character spacing to point 4 | |
| fs.TextOptions.Spacing = 4; | |
| // Save the workbook in xlsx format | |
| wb.Save(outputDir + "outputChangeTextBoxOrShapeCharacterSpacing.xlsx", SaveFormat.Xlsx); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| //Source directory | |
| string sourceDir = RunExamples.Get_SourceDirectory(); | |
| //Output directory | |
| string outputDir = RunExamples.Get_OutputDirectory(); | |
| LoadOptions options = new LoadOptions(LoadFormat.Xlsx); | |
| options.CultureInfo = new CultureInfo("ja-JP"); | |
| Workbook workbook = new Workbook(sourceDir + "JapaneseDates.xlsx", options); | |
| workbook.Save(outputDir + "JapaneseDates.pdf", SaveFormat.Pdf); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| //Source directory | |
| string sourceDir = RunExamples.Get_SourceDirectory(); | |
| //Output directory | |
| string outputDir = RunExamples.Get_OutputDirectory(); | |
| Workbook book = new Workbook(sourceDir + "sampleConvertWorksheetToImageByPage.xlsx"); | |
| Worksheet sheet = book.Worksheets[0]; | |
| Aspose.Cells.Rendering.ImageOrPrintOptions options = new Aspose.Cells.Rendering.ImageOrPrintOptions(); | |
| options.HorizontalResolution = 200; | |
| options.VerticalResolution = 200; | |
| options.ImageType = Drawing.ImageType.Tiff; | |
| // Sheet2Image By Page conversion | |
| SheetRender sr = new SheetRender(sheet, options); | |
| for (int j = 0; j < sr.PageCount; j++) | |
| { | |
| sr.ToImage(j, outputDir + "outputConvertWorksheetToImageByPage_" + (j + 1) + ".tif"); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| //Source directory | |
| string sourceDir = RunExamples.Get_SourceDirectory(); | |
| //Output directory | |
| string outputDir = RunExamples.Get_OutputDirectory(); | |
| // Open a template excel file | |
| Workbook book = new Workbook(sourceDir + "sampleConvertWorksheettoImageFile.xlsx"); | |
| // Get the first worksheet. | |
| Worksheet sheet = book.Worksheets[0]; | |
| // Define ImageOrPrintOptions | |
| ImageOrPrintOptions imgOptions = new ImageOrPrintOptions(); | |
| imgOptions.OnePagePerSheet = true; | |
| // Specify the image format | |
| imgOptions.ImageType = Drawing.ImageType.Jpeg; | |
| // Render the sheet with respect to specified image/print options | |
| SheetRender sr = new SheetRender(sheet, imgOptions); | |
| // Render the image for the sheet | |
| Bitmap bitmap = sr.ToImage(0); | |
| // Save the image file | |
| bitmap.Save(outputDir + "outputConvertWorksheettoImageFile.jpg"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| //Output directory | |
| string outputDir = RunExamples.Get_OutputDirectory(); | |
| // Instantiate a workbook | |
| var workbook = new Workbook(); | |
| // Put sample text in the first cell of first worksheet in the newly created workbook | |
| workbook.Worksheets[0].Cells["A1"].Value = "DEMO TEXT ON SHEET1"; | |
| // Add second worksheet in the workbook | |
| workbook.Worksheets.Add(SheetType.Worksheet); | |
| // Set text in first cell of the second sheet | |
| workbook.Worksheets[1].Cells["A1"].Value = "DEMO TEXT ON SHEET2"; | |
| // Set currently active sheet incex to 1 i.e. Sheet2 | |
| workbook.Worksheets.ActiveSheetIndex = 1; | |
| // Save workbook to SVG. It shall render the active sheet only to SVG | |
| workbook.Save(outputDir + "ConvertWorksheetToSVG_out.svg"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| //Source directory | |
| string sourceDir = RunExamples.Get_SourceDirectory(); | |
| //Output directory | |
| string outputDir = RunExamples.Get_OutputDirectory(); | |
| // Create workbook object from source file | |
| Workbook wb = new Workbook(sourceDir + "sampleCreateTransparentImage.xlsx"); | |
| // Apply different image or print options | |
| var imgOption = new ImageOrPrintOptions(); | |
| imgOption.ImageType = Drawing.ImageType.Png; | |
| imgOption.HorizontalResolution = 200; | |
| imgOption.VerticalResolution = 200; | |
| imgOption.OnePagePerSheet = true; | |
| // Apply transparency to the output image | |
| imgOption.Transparent = true; | |
| // Create image after apply image or print options | |
| var sr = new SheetRender(wb.Worksheets[0], imgOption); | |
| sr.ToImage(0, outputDir + "outputCreateTransparentImage.png"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| //Source directory | |
| string sourceDir = RunExamples.Get_SourceDirectory(); | |
| //Output directory | |
| string outputDir = RunExamples.Get_OutputDirectory(); | |
| // Open a template Excel file | |
| Workbook workbook = new Workbook(sourceDir + "sampleExtractImagesFromWorksheets.xlsx"); | |
| // Get the first worksheet | |
| Worksheet worksheet = workbook.Worksheets[0]; | |
| // Get the first Picture in the first worksheet | |
| Aspose.Cells.Drawing.Picture pic = worksheet.Pictures[0]; | |
| // Set the output image file path | |
| string picformat = pic.ImageType.ToString(); | |
| // Note: you may evaluate the image format before specifying the image path | |
| // Define ImageOrPrintOptions | |
| ImageOrPrintOptions printoption = new ImageOrPrintOptions(); | |
| // Specify the image format | |
| printoption.ImageType = Drawing.ImageType.Jpeg; | |
| // Save the image | |
| pic.ToImage(outputDir + "outputExtractImagesFromWorksheets.jpg", printoption); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| //Source directory | |
| string sourceDir = RunExamples.Get_SourceDirectory(); | |
| //Output directory | |
| string outputDir = RunExamples.Get_OutputDirectory(); | |
| // Instantiate and open an Excel file | |
| Workbook book = new Workbook(sourceDir + "sampleGenerateThumbnailOfWorksheet.xlsx"); | |
| // Define ImageOrPrintOptions | |
| ImageOrPrintOptions imgOptions = new ImageOrPrintOptions(); | |
| // Specify the image format | |
| imgOptions.ImageType = Drawing.ImageType.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[0]; | |
| // 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(600, 600); | |
| // 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, 600, 600); | |
| } | |
| // Save the thumbnail | |
| thumb.Save(outputDir + "outputGenerateThumbnailOfWorksheet.bmp"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // In order to save the chart image, create an instance of ImageOrPrintOptions | |
| ImageOrPrintOptions anOption = new ImageOrPrintOptions(); | |
| // Set image format | |
| anOption.ImageType = Drawing.ImageType.Png; | |
| // Set resolution | |
| anOption.HorizontalResolution = 200; | |
| anOption.VerticalResolution = 200; | |
| // Render chart to image | |
| chart.ToImage(dataDir + "output_out.png", anOption); | |
| // Save the workbook to see chart inside the Excel | |
| workbook.Save(dataDir + "output_out.xlsx"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| //Source directory | |
| string sourceDir = RunExamples.Get_SourceDirectory(); | |
| //Output directory | |
| string outputDir = RunExamples.Get_OutputDirectory(); | |
| // Create workbook from source file | |
| Workbook workbook = new Workbook(sourceDir + "sampleRefreshValueOfLinkedShapes.xlsx"); | |
| // Access first worksheet | |
| Worksheet worksheet = workbook.Worksheets[0]; | |
| // Change the value of cell B4 | |
| Cell cell = worksheet.Cells["B4"]; | |
| cell.PutValue(100); | |
| // Update the value of the Linked Picture which is linked to cell B4 | |
| worksheet.Shapes.UpdateSelectedValue(); | |
| // Save the workbook in PDF format | |
| workbook.Save(outputDir + "outputRefreshValueOfLinkedShapes.pdf", SaveFormat.Pdf); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| //Source directory | |
| string sourceDir = RunExamples.Get_SourceDirectory(); | |
| //Output directory | |
| string outputDir = RunExamples.Get_OutputDirectory(); | |
| // Create workbook object from source excel file | |
| Workbook workbook = new Workbook(sourceDir + "sampleGenerateDatabarImage.xlsx"); | |
| // Access first worksheet | |
| Worksheet worksheet = workbook.Worksheets[0]; | |
| // Access the cell which contains conditional formatting databar | |
| Cell cell = worksheet.Cells["C1"]; | |
| // Create and get the conditional formatting of the worksheet | |
| int idx = worksheet.ConditionalFormattings.Add(); | |
| FormatConditionCollection fcc = worksheet.ConditionalFormattings[idx]; | |
| fcc.AddCondition(FormatConditionType.DataBar); | |
| fcc.AddArea(CellArea.CreateCellArea("C1", "C4")); | |
| // Access the conditional formatting databar | |
| DataBar dbar = fcc[0].DataBar; | |
| // Create image or print options | |
| ImageOrPrintOptions opts = new ImageOrPrintOptions(); | |
| opts.ImageType = Drawing.ImageType.Png; | |
| // Get the image bytes of the databar | |
| byte[] imgBytes = dbar.ToImage(cell, opts); | |
| // Write image bytes on the disk | |
| File.WriteAllBytes(outputDir + "outputGenerateDatabarImage.png", imgBytes); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| string password = "1234"; | |
| string pfxPath = sourceDir + "sampleDigitallySignVbaProjectWithCertificate.pfx"; | |
| string comment = "Signing Digital Signature using Aspose.Cells"; | |
| // Set Digital Signature | |
| DigitalSignature digitalSignature = new DigitalSignature(File.ReadAllBytes(pfxPath), password, comment, DateTime.Now); | |
| // Create workbook object from excel file | |
| Workbook workbook = new Workbook(sourceDir + "sampleDigitallySignVbaProjectWithCertificate.xlsm"); | |
| // Sign VBA Code Project with Digital Signature | |
| workbook.VbaProject.Sign(digitalSignature); | |
| // Save the workbook | |
| workbook.Save(outputDir + "outputDigitallySignVbaProjectWithCertificate.xlsm"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Create workbook object from source excel file | |
| Workbook workbook = new Workbook(sourceDir + "sourcePivotTable.xlsx"); | |
| // Access first worksheet | |
| Worksheet worksheet = workbook.Worksheets[0]; | |
| // Access first pivot table inside the worksheet | |
| PivotTable pivotTable = worksheet.PivotTables[0]; | |
| // Access pivot table refresh by who | |
| Console.WriteLine("Pivot table refresh by who = " + pivotTable.RefreshedByWho); | |
| // Access pivot table refresh date | |
| Console.WriteLine("Pivot table refresh date = " + pivotTable.RefreshDate); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| //Source directory | |
| string sourceDir = RunExamples.Get_SourceDirectory(); | |
| //Output directory | |
| string outputDir = RunExamples.Get_OutputDirectory(); | |
| // Create a workbook | |
| Workbook wb = new Workbook(sourceDir + "sampleUpdateActiveXComboBoxControl.xlsx"); | |
| // Access first shape from first worksheet | |
| Shape shape = wb.Worksheets[0].Shapes[0]; | |
| // Access ActiveX ComboBox Control and update its value | |
| if (shape.ActiveXControl != null) | |
| { | |
| // Remove Shape ActiveX Control | |
| shape.RemoveActiveXControl(); | |
| } | |
| // Save the workbook | |
| wb.Save(outputDir + "RemoveActiveXControl_our.xlsx"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| //Source directory | |
| string sourceDir = RunExamples.Get_SourceDirectory(); | |
| //Output directory | |
| string outputDir = RunExamples.Get_OutputDirectory(); | |
| // Open the template file | |
| Workbook book = new Workbook(sourceDir + "Book1.xlsx"); | |
| // Get the first worksheet | |
| Worksheet sheet = book.Worksheets[0]; | |
| LoadOptions options = new LoadOptions(); | |
| options.LoadFilter = new LoadFilter(LoadDataFilterOptions.All); | |
| // Specify your print area if you want | |
| // Sheet.PageSetup.PrintArea = "A1:H8"; | |
| // To remove the white border around the image. | |
| sheet.PageSetup.LeftMargin = 0; | |
| sheet.PageSetup.RightMargin = 0; | |
| sheet.PageSetup.BottomMargin = 0; | |
| sheet.PageSetup.TopMargin = 0; | |
| // Define ImageOrPrintOptions | |
| ImageOrPrintOptions imgOptions = new ImageOrPrintOptions(); | |
| imgOptions.ImageType = Drawing.ImageType.Emf; | |
| // Set only one page would be rendered for the image | |
| imgOptions.OnePagePerSheet = true; | |
| imgOptions.PrintingPage = PrintingPageType.IgnoreBlank; | |
| // Create the SheetRender object based on the sheet with its | |
| // ImageOrPrintOptions attributes | |
| SheetRender sr = new SheetRender(sheet, imgOptions); | |
| // Convert the image | |
| sr.ToImage(0, outputDir + "outputRemoveWhitespaceAroundData.emf"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| //Source directory | |
| string sourceDir = RunExamples.Get_SourceDirectory(); | |
| // Instantiate a workbook with an Excel file. | |
| Workbook workbook = new Workbook(sourceDir + "samplePrintingUsingWorkbookRender.xlsx"); | |
| string printerName = "doPDF 8"; | |
| // Apply different Image/Print options. | |
| Aspose.Cells.Rendering.ImageOrPrintOptions options = new Aspose.Cells.Rendering.ImageOrPrintOptions(); | |
| options.ImageType = Drawing.ImageType.Tiff; | |
| options.PrintingPage = PrintingPageType.Default; | |
| // To print a whole workbook, iterate through the sheets and print them, or use the WorkbookRender class. | |
| WorkbookRender wr = new WorkbookRender(workbook, options); | |
| try | |
| { | |
| // Print the workbook. | |
| wr.ToPrinter(printerName); | |
| } | |
| catch (Exception ex) | |
| { | |
| Console.WriteLine(ex.Message); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // The path to the documents directory. | |
| string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | |
| // Create workbook object. | |
| Workbook wb = new Workbook(); | |
| // Set default font of the workbook to none | |
| Style s = wb.DefaultStyle; | |
| s.Font.Name = ""; | |
| wb.DefaultStyle = s; | |
| // Access first worksheet. | |
| Worksheet ws = wb.Worksheets[0]; | |
| // Access cell A4 and add some text inside it. | |
| Cell cell = ws.Cells["A4"]; | |
| cell.PutValue("This text has some unknown or invalid font which does not exist."); | |
| // Set the font of cell A4 which is unknown. | |
| Style st = cell.GetStyle(); | |
| st.Font.Name = "UnknownNotExist"; | |
| st.Font.Size = 20; | |
| st.IsTextWrapped = true; | |
| cell.SetStyle(st); | |
| // Set first column width and fourth column height | |
| ws.Cells.SetColumnWidth(0, 80); | |
| ws.Cells.SetRowHeight(3, 60); | |
| // Create image or print options. | |
| ImageOrPrintOptions opts = new ImageOrPrintOptions(); | |
| opts.OnePagePerSheet = true; | |
| opts.ImageType = Drawing.ImageType.Png; | |
| // Render worksheet image with Courier New as default font. | |
| opts.DefaultFont = "Courier New"; | |
| SheetRender sr = new SheetRender(ws, opts); | |
| sr.ToImage(0, "out_courier_new_out.png"); | |
| // Render worksheet image again with Times New Roman as default font. | |
| opts.DefaultFont = "Times New Roman"; | |
| sr = new SheetRender(ws, opts); | |
| sr.ToImage(0, "times_new_roman_out.png"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| //Source directory | |
| string sourceDir = RunExamples.Get_SourceDirectory(); | |
| //Output directory | |
| string outputDir = RunExamples.Get_OutputDirectory(); | |
| // Create workbook object from source file | |
| Workbook workbook = new Workbook(sourceDir + "sampleWorksheetToImageDesiredSize.xlsx"); | |
| // Access first worksheet | |
| Worksheet worksheet = workbook.Worksheets[0]; | |
| // Set image or print options we want one page per sheet. The image format is in png and desired dimensions are 400x400 | |
| Aspose.Cells.Rendering.ImageOrPrintOptions opts = new Aspose.Cells.Rendering.ImageOrPrintOptions(); | |
| opts.OnePagePerSheet = true; | |
| opts.ImageType = Drawing.ImageType.Png; | |
| opts.SetDesiredSize(400, 400); | |
| // Render sheet into image | |
| Aspose.Cells.Rendering.SheetRender sr = new Aspose.Cells.Rendering.SheetRender(worksheet, opts); | |
| sr.ToImage(0, outputDir + "outputWorksheetToImageDesiredSize.png"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| Workbook wb = new Workbook(sourceDir + "SmartArt.xlsx"); | |
| foreach (Worksheet worksheet in wb.Worksheets) | |
| { | |
| foreach (Shape shape in worksheet.Shapes) | |
| { | |
| shape.AlternativeText = "ReplacedAlternativeText"; // This works fine just as the normal Shape objects do. | |
| if (shape.IsSmartArt) | |
| { | |
| foreach (Shape smartart in shape.GetResultOfSmartArt().GetGroupedShapes()) | |
| { | |
| smartart.Text = "ReplacedText"; // This doesn't update the text in Workbook which I save to the another file. | |
| } | |
| } | |
| } | |
| } | |
| Aspose.Cells.OoxmlSaveOptions options = new Aspose.Cells.OoxmlSaveOptions(); | |
| options.UpdateSmartArt = true; | |
| wb.Save(outputDir + "outputSmartArt.xlsx", options); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| //Source directory | |
| string sourceDir = RunExamples.Get_SourceDirectory(); | |
| //Output directory | |
| string outputDir = RunExamples.Get_OutputDirectory(); | |
| // Instantiate a new Workbook. | |
| Workbook workbook = new Workbook(); | |
| // Get the first worksheet. | |
| Worksheet sheet = workbook.Worksheets[0]; | |
| // Set the background image for the sheet. | |
| sheet.BackgroundImage = File.ReadAllBytes(sourceDir + "background.jpg"); | |
| // Save the Excel file | |
| workbook.Save(outputDir + "outputBackImageSheet.xlsx"); | |
| // Save the HTML file | |
| workbook.Save(outputDir + "outputBackImageSheet.html", SaveFormat.Html); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| //Source directory | |
| string sourceDir = RunExamples.Get_SourceDirectory(); | |
| //Output directory | |
| string outputDir = RunExamples.Get_OutputDirectory(); | |
| // Load an Excel file | |
| Workbook wb = new Workbook(sourceDir + "sampleSetPixelFormatRenderedImage.xlsx"); | |
| //Access first worksheet | |
| Worksheet ws = wb.Worksheets[0]; | |
| // Set the ImageOrPrintOptions with desired pixel format (24 bits per pixel) and image format type | |
| ImageOrPrintOptions opts = new ImageOrPrintOptions(); | |
| opts.PixelFormat = PixelFormat.Format24bppRgb; | |
| opts.ImageType = Drawing.ImageType.Tiff; | |
| // Instantiate SheetRender object based on the first worksheet | |
| SheetRender sr = new SheetRender(ws, opts); | |
| // Save the image (first page of the sheet) with the specified options | |
| sr.ToImage(0, outputDir + "outputSetPixelFormatRenderedImage.tiff"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| //Output directory | |
| string outputDir = RunExamples.Get_OutputDirectory(); | |
| // Create workbook object | |
| Workbook wb = new Workbook(); | |
| // Access first worksheet | |
| Worksheet ws = wb.Worksheets[0]; | |
| // Add text box with these dimensions | |
| TextBox tb = ws.Shapes.AddTextBox(2, 0, 2, 0, 100, 400); | |
| // Set the text of the textbox | |
| tb.Text = "This text has the following settings.\n\nText Effects > Shadow > Offset Bottom"; | |
| // Set all the text runs shadow to preset offset bottom | |
| for (int i = 0; i < tb.TextBody.Count; i++) | |
| { | |
| tb.TextBody[i].TextOptions.Shadow.PresetType = PresetShadowType.OffsetBottom; | |
| } | |
| // Set the font color and size of the textbox | |
| tb.Font.Color = Color.Red; | |
| tb.Font.Size = 16; | |
| // Save the output file | |
| wb.Save(outputDir + "outputSettingTextEffectsShadowOfShapeOrTextbox.xlsx", SaveFormat.Xlsx); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| //Source directory | |
| string sourceDir = RunExamples.Get_SourceDirectory(); | |
| //Output directory | |
| string outputDir = RunExamples.Get_OutputDirectory(); | |
| // Open a template excel file | |
| Workbook book = new Workbook(sourceDir + "sampleSpecificPagesToImages.xlsx"); | |
| // Get the first worksheet. | |
| Worksheet sheet = book.Worksheets[0]; | |
| // Define ImageOrPrintOptions | |
| ImageOrPrintOptions imgOptions = new ImageOrPrintOptions(); | |
| // Specify the image format | |
| imgOptions.ImageType = Drawing.ImageType.Jpeg; | |
| // Render the sheet with respect to specified image/print options | |
| SheetRender sr = new SheetRender(sheet, imgOptions); | |
| //Specify page index to be rendered | |
| int idxPage = 3; | |
| // Render the third image for the sheet | |
| Bitmap bitmap = sr.ToImage(idxPage); | |
| // Save the image file | |
| bitmap.Save(outputDir + "outputSpecificPagesToImage_"+ (idxPage+1)+".jpg"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| //Source directory | |
| string sourceDir = RunExamples.Get_SourceDirectory(); | |
| //Output directory | |
| string outputDir = RunExamples.Get_OutputDirectory(); | |
| Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(sourceDir + "sampleUseWorkbookRenderForImageConversion.xlsx"); | |
| ImageOrPrintOptions opts = new ImageOrPrintOptions(); | |
| opts.ImageType = Drawing.ImageType.Tiff; | |
| WorkbookRender wr = new WorkbookRender(wb, opts); | |
| wr.ToImage(outputDir + "outputUseWorkbookRenderForImageConversion.tiff"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| //Source directory | |
| string sourceDir = RunExamples.Get_SourceDirectory(); | |
| //Output directory | |
| string outputDir = RunExamples.Get_OutputDirectory(); | |
| //Open template | |
| Workbook book = new Workbook(sourceDir + "sampleWorksheetToAnImage.xlsx"); | |
| // Get the first worksheet | |
| Worksheet sheet = book.Worksheets[0]; | |
| // Apply different Image and Print options | |
| Aspose.Cells.Rendering.ImageOrPrintOptions options = new Aspose.Cells.Rendering.ImageOrPrintOptions(); | |
| // Set Horizontal Resolution | |
| options.HorizontalResolution = 300; | |
| // Set Vertical Resolution | |
| options.VerticalResolution = 300; | |
| // Set TiffCompression | |
| options.TiffCompression = Aspose.Cells.Rendering.TiffCompression.CompressionLZW; | |
| // Set Autofit options | |
| options.IsCellAutoFit = false; | |
| // Set Image Format | |
| options.ImageType = Drawing.ImageType.Tiff; | |
| // Set printing page type | |
| options.PrintingPage = PrintingPageType.Default; | |
| // Render the sheet with respect to specified image/print options | |
| SheetRender sr = new SheetRender(sheet, options); | |
| // Render/save the image for the sheet | |
| int pageIndex = 3; | |
| sr.ToImage(pageIndex, outputDir + @"outputWorksheetToAnImage_"+ (pageIndex + 1) + ".tiff"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // The path to the documents directory. | |
| string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | |
| // Create workbook | |
| Workbook workbook = new Workbook(); | |
| Cells cells = workbook.Worksheets[0].Cells; | |
| // Set formula | |
| Cell cell = cells[0, 0]; | |
| cell.SetArrayFormula("=MYFUNC()", 2, 2); | |
| Style style = cell.GetStyle(); | |
| style.Number = 14; | |
| cell.SetStyle(style); | |
| // Set calculation options for formula | |
| CalculationOptions calculationOptions = new CalculationOptions(); | |
| calculationOptions.CustomEngine = new CustomFunctionStaticValue(); | |
| workbook.CalculateFormula(calculationOptions); | |
| // Save to xlsx by setting the calc mode to manual | |
| workbook.Settings.CalcMode = CalcModeType.Manual; | |
| workbook.Save(dataDir + "output_out.xlsx"); | |
| // Save to pdf | |
| workbook.Save(dataDir + "output_out.pdf"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| public class CustomFunctionStaticValue : AbstractCalculationEngine | |
| { | |
| public override void Calculate(CalculationData data) | |
| { | |
| data.CalculatedValue = new object[][] { | |
| new object[]{new DateTime(2015, 6, 12, 10, 6, 30), 2}, | |
| new object[]{3.0, "Test"} | |
| }; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| public class CustomFunction : AbstractCalculationEngine | |
| { | |
| public override void Calculate(CalculationData data) | |
| { | |
| decimal total = 0M; | |
| try | |
| { | |
| // Get value of first parameter | |
| object firstParameter = data.GetParamValue(0); | |
| Console.WriteLine(data.GetParamValue(0).GetType()); | |
| decimal firstParamB1 = 0; | |
| if (firstParameter is ReferredArea) | |
| { | |
| ReferredArea ra = (ReferredArea)firstParameter; | |
| firstParamB1 = System.Convert.ToDecimal(ra.GetValue(0, 0)); | |
| } | |
| // Get value of second parameter | |
| object secondParameter = data.GetParamValue(1); | |
| Console.WriteLine(data.GetParamValue(1).GetType()); | |
| if (secondParameter is ReferredArea) | |
| { | |
| ReferredArea ra = (ReferredArea)secondParameter; | |
| // get every item value of second parameter | |
| foreach (object[] value in (Array)ra.GetValues()) | |
| { | |
| total += System.Convert.ToDecimal(value[0]); | |
| } | |
| } | |
| total = total / firstParamB1; | |
| } | |
| catch | |
| { | |
| } | |
| // Result of the function | |
| data.CalculatedValue = total; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // The path to the documents directory. | |
| string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | |
| // Open the workbook | |
| Workbook workbook = new Workbook(); | |
| // Obtaining the reference of the first worksheet | |
| Worksheet worksheet = workbook.Worksheets[0]; | |
| // Adding sample values to cells | |
| worksheet.Cells["B1"].PutValue(5); | |
| worksheet.Cells["C1"].PutValue(100); | |
| worksheet.Cells["C2"].PutValue(150); | |
| worksheet.Cells["C3"].PutValue(60); | |
| worksheet.Cells["C4"].PutValue(32); | |
| worksheet.Cells["C5"].PutValue(62); | |
| // Adding custom formula to Cell A1 | |
| workbook.Worksheets[0].Cells["A1"].Formula = "=MyFunc(B1,C1:C5)"; | |
| // Set calculation options | |
| CalculationOptions calculationOptions = new CalculationOptions(); | |
| calculationOptions.CustomEngine = new CustomFunction(); | |
| // Calcualting Formulas | |
| workbook.CalculateFormula(calculationOptions); | |
| // Assign resultant value to Cell A1 | |
| workbook.Worksheets[0].Cells["A1"].PutValue(workbook.Worksheets[0].Cells["A1"].Value); | |
| // Save the file | |
| workbook.Save(dataDir + "UsingAbstractCalculationEnginefeature_out.xls"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| Workbook workbook = new Workbook(sourceDir + "GetTextWidthSample.xlsx"); | |
| Console.WriteLine("Text width: " + CellsHelper.GetTextWidth(workbook.Worksheets[0].Cells["A1"].StringValue, workbook.DefaultStyle.Font, 1)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| Workbook workbook = new Workbook(sourceDir + "SampleChangeTickLabelDirection.xlsx"); | |
| Worksheet worksheet = workbook.Worksheets[0]; | |
| // Load the chart from source worksheet | |
| Chart chart = worksheet.Charts[0]; | |
| chart.CategoryAxis.TickLabels.DirectionType = ChartTextDirectionType.Horizontal; | |
| // Output the file | |
| workbook.Save(outputDir + "outputChangeChartDataLableDirection.xlsx"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| //Source directory | |
| string sourceDir = RunExamples.Get_SourceDirectory(); | |
| // Load excel file containing charts | |
| Workbook workbook = new Workbook(sourceDir + "SampleChart.ods"); | |
| // Access first worksheet | |
| Worksheet worksheet = workbook.Worksheets[0]; | |
| // Access first chart inside the worksheet | |
| Chart chart = worksheet.Charts[0]; | |
| Console.WriteLine("Chart Subtitle: " + chart.SubTitle.Text); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Instantiating a Workbook object | |
| Workbook workbook = new Workbook(); | |
| // Adding a chart to the worksheet | |
| int index = workbook.Worksheets.Add(SheetType.Chart); | |
| Worksheet sheet = workbook.Worksheets[index]; | |
| sheet.Charts.AddFloatingChart(ChartType.Column, 0, 0, 1024, 960); | |
| sheet.Charts[0].NSeries.Add("{1,2,3}", false); | |
| // Add checkbox to the chart. | |
| sheet.Charts[0].Shapes.AddShapeInChart(MsoDrawingType.CheckBox, PlacementType.Move, 400, 400, 1000, 600); | |
| sheet.Charts[0].Shapes[0].Text = "CheckBox 1"; | |
| // Save the excel file. | |
| workbook.Save(outputDir + "InsertCheckboxInChartSheet_out.xlsx"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // 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 first worksheet | |
| Worksheet worksheet = workbook.Worksheets[0]; | |
| // Adding sample values to cells | |
| worksheet.Cells["A2"].PutValue("Category1"); | |
| worksheet.Cells["A3"].PutValue("Category2"); | |
| worksheet.Cells["A4"].PutValue("Category3"); | |
| worksheet.Cells["B1"].PutValue("Column1"); | |
| worksheet.Cells["B2"].PutValue(4); | |
| worksheet.Cells["B3"].PutValue(20); | |
| worksheet.Cells["B4"].PutValue(50); | |
| worksheet.Cells["C1"].PutValue("Column2"); | |
| worksheet.Cells["C2"].PutValue(50); | |
| worksheet.Cells["C3"].PutValue(100); | |
| worksheet.Cells["C4"].PutValue(150); | |
| // Adding a chart to the worksheet | |
| int chartIndex = worksheet.Charts.Add(Aspose.Cells.Charts.ChartType.Column, 5, 0, 15, 5); | |
| // Accessing the instance of the newly added chart | |
| Aspose.Cells.Charts.Chart chart = worksheet.Charts[chartIndex]; | |
| // Setting chart data source as the range "A1:C4" | |
| chart.SetChartDataRange("A1:C4", true); | |
| // Saving the Excel file | |
| workbook.Save(dataDir + "output.xls"); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // directories | |
| string SourceDir = RunExamples.Get_SourceDirectory(); | |
| string outputDir = RunExamples.Get_OutputDirectory(); | |
| Workbook workbook = new Workbook(SourceDir + "ValidationsSample.xlsx"); | |
| // Access first worksheet. | |
| Worksheet worksheet = workbook.Worksheets[0]; | |
| // Accessing the Validations collection of the worksheet | |
| Validation validation = worksheet.Validations[0]; | |
| // Create your cell area. | |
| CellArea cellArea = CellArea.CreateCellArea("D5", "E7"); | |
| // Adding the cell area to Validation | |
| validation.AddArea(cellArea, false, false); | |
| // Save the output workbook. | |
| workbook.Save(outputDir + "ValidationsSample_out.xlsx"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Output directory | |
| string outputDir = RunExamples.Get_OutputDirectory(); | |
| // Instantiating a Workbook object | |
| Workbook workbook = new Workbook(); | |
| // Create union range | |
| UnionRange unionRange = workbook.Worksheets.CreateUnionRange("sheet1!A1:A10,sheet1!C1:C10", 0); | |
| // Put value "ABCD" in the range | |
| unionRange.Value = "ABCD"; | |
| // Save the output workbook. | |
| workbook.Save(outputDir + "CreateUnionRange_out.xlsx"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| public class ImportCustomObjectsToMergedArea | |
| { | |
| public static void Run() | |
| { | |
| //Source directory | |
| string sourceDir = RunExamples.Get_SourceDirectory(); | |
| //Output directory | |
| string outputDir = RunExamples.Get_OutputDirectory(); | |
| Workbook workbook = new Workbook(sourceDir + "sampleMergedTemplate.xlsx"); | |
| List<Product> productList = new List<Product>(); | |
| //Creating collection of test items | |
| for (int i = 0; i < 3; i++) | |
| { | |
| Product product = new Product | |
| { | |
| ProductId = i, | |
| ProductName = "Test Product - " + i | |
| }; | |
| productList.Add(product); | |
| } | |
| ImportTableOptions tableOptions = new ImportTableOptions(); | |
| tableOptions.CheckMergedCells = true; | |
| tableOptions.IsFieldNameShown = false; | |
| //Insert data to excel template | |
| workbook.Worksheets[0].Cells.ImportCustomObjects((ICollection)productList, 1, 0, tableOptions); | |
| workbook.Save(outputDir + "sampleMergedTemplate_out.xlsx", SaveFormat.Xlsx); | |
| Console.WriteLine("ImportCustomObectsToMergedArea executed successfully.\r\n"); | |
| } | |
| } | |
| public class Product | |
| { | |
| public int ProductId { get; set; } | |
| public string ProductName { get; set; } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // The path to the documents directory. | |
| string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | |
| // Instantiating a Workbook object | |
| Workbook workbook = new Workbook(); | |
| Worksheet worksheet = workbook.Worksheets[0]; | |
| // Read File | |
| string jsonInput = File.ReadAllText(dataDir + "Test.json"); | |
| // Set Styles | |
| CellsFactory factory = new CellsFactory(); | |
| Style style = factory.CreateStyle(); | |
| style.HorizontalAlignment = TextAlignmentType.Center; | |
| style.Font.Color = System.Drawing.Color.BlueViolet; | |
| style.Font.IsBold = true; | |
| // Set JsonLayoutOptions | |
| JsonLayoutOptions options = new JsonLayoutOptions(); | |
| options.TitleStyle = style; | |
| options.ArrayAsTable = true; | |
| // Import JSON Data | |
| JsonUtility.ImportData(jsonInput, worksheet.Cells, 0, 0, options); | |
| // Save Excel file | |
| workbook.Save(dataDir + "ImportingFromJson.out.xlsx"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Create a workbook object and load template file | |
| Workbook workbook = new Workbook(sourceDir + "CellsNet46500.xlsx"); | |
| // Instantiate data sorter object | |
| DataSorter sorter = workbook.DataSorter; | |
| // Add key for second column for red color | |
| sorter.AddKey(1, SortOnType.CellColor, SortOrder.Descending, Color.Red); | |
| // Sort the data based on the key | |
| sorter.Sort(workbook.Worksheets[0].Cells, CellArea.CreateCellArea("A2", "C6")); | |
| // Save the output file | |
| workbook.Save(outputDir + "outputSortData_CustomSortList.xlsx"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Instantiate a new Workbook. | |
| Workbook workbook = new Workbook(); | |
| // Get the first worksheet in the book. | |
| Worksheet worksheet = workbook.Worksheets[0]; | |
| // Add a new textbox to the collection. | |
| int textboxIndex = worksheet.TextBoxes.Add(2, 1, 160, 200); | |
| // Access your text box which is also a shape object from shapes collection | |
| Shape shape = workbook.Worksheets[0].Shapes[0]; | |
| // Get all the connection points in this shape | |
| var ConnectionPoints = shape.ConnectionPoints; | |
| // Display all the shape points | |
| foreach (var pt in ConnectionPoints) | |
| { | |
| System.Console.WriteLine(string.Format("X = {0}, Y = {1}", pt.X, pt.Y)); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // 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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| //Source directory | |
| string sourceDir = RunExamples.Get_SourceDirectory(); | |
| var filename = sourceDir + "[20180220142533][ASPOSE_CELLS_TEST].csv"; | |
| //Load CSV file | |
| var workbook = new Workbook(filename, new TxtLoadOptions() { Separator = ';', LoadFilter = new LoadFilter(LoadDataFilterOptions.CellData), CheckExcelRestriction = false, ConvertNumericData = false, ConvertDateTimeData = false }); | |
| Console.WriteLine(workbook.Worksheets[0].Name); // (20180220142533)(ASPOSE_CELLS_T | |
| Console.WriteLine(workbook.Worksheets[0].Name.Length); // 31 | |
| Console.WriteLine("CSV file opened successfully!"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| //Source directory | |
| string sourceDir = RunExamples.Get_SourceDirectory(); | |
| // Instantiate LoadOptions specified by the LoadFormat. | |
| LoadOptions loadOptions = new LoadOptions(LoadFormat.FODS); | |
| // Create a Workbook object and opening the file from its path | |
| Workbook workbook = new Workbook(sourceDir + "SampleFods.fods", loadOptions); | |
| Console.WriteLine("FODS file opened successfully!"); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // The path to the documents directory. | |
| string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | |
| // Get the Excel file into stream | |
| FileStream stream = new FileStream(dataDir + "Book_Excel97_2003.xls", FileMode.Open); | |
| // Instantiate LoadOptions specified by the LoadFormat. | |
| LoadOptions loadOptions1 = new LoadOptions(LoadFormat.Excel97To2003); | |
| // Create a Workbook object and opening the file from the stream | |
| Workbook wbExcel97 = new Workbook(stream, loadOptions1); | |
| Console.WriteLine("Microsoft Excel 97 - 2003 workbook opened successfully!"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| //Source directory | |
| string sourceDir = RunExamples.Get_SourceDirectory(); | |
| // Instantiate LoadOptions specified by the LoadFormat. | |
| LoadOptions loadOptions = new LoadOptions(LoadFormat.SXC); | |
| // Create a Workbook object and opening the file from its path | |
| Workbook workbook = new Workbook(sourceDir + "SampleSXC.sxc", loadOptions); | |
| // Using the Sheet 1 in Workbook | |
| Worksheet worksheet = workbook.Worksheets[0]; | |
| // Accessing a cell using its name | |
| Cell cell = worksheet.Cells["C3"]; | |
| Console.WriteLine("Cell Name: " + cell.Name + " Value: " + cell.StringValue); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| //Source directory | |
| string sourceDir = RunExamples.Get_SourceDirectory(); | |
| // Instantiate LoadOptions specified by the LoadFormat. | |
| LoadOptions loadOptions = new LoadOptions(LoadFormat.TSV); | |
| // Create a Workbook object and opening the file from its path | |
| Workbook workbook = new Workbook(sourceDir + "SampleTSVFile.tsv", loadOptions); | |
| // Using the Sheet 1 in Workbook | |
| Worksheet worksheet = workbook.Worksheets[0]; | |
| // Accessing a cell using its name | |
| Cell cell = worksheet.Cells["C3"]; | |
| Console.WriteLine("Cell Name: " + cell.Name + " Value: " + cell.StringValue); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| //Output directory | |
| string outputDir = RunExamples.Get_OutputDirectory(); | |
| // Create a Workbook object and opening the file from its path | |
| //Workbook workbook = new Workbook(sourceDir + "Book_CSV.csv", loadOptions); | |
| Workbook workbook = new Workbook(); | |
| Worksheet worksheet = workbook.Worksheets[0]; | |
| worksheet.Cells[0, 0].Value = 1; | |
| worksheet.Cells[1, 0].Value = 2; | |
| worksheet.Cells[2, 0].Value = 3; | |
| worksheet.Cells[2, 2].Value = 4; | |
| workbook.Save(outputDir + "SaveFODSFiles.fods", SaveFormat.SXC); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| //Source directory | |
| string sourceDir = RunExamples.Get_SourceDirectory(); | |
| var filename = sourceDir + "encryptedBook1.out.tmp"; | |
| Stream stream = File.Open(filename, FileMode.Open); | |
| FileFormatInfo fileFormatInfo = FileFormatUtil.DetectFileFormat(stream, "1234"); // The password is 1234 | |
| Console.WriteLine("File Format: " + fileFormatInfo.FileFormatType); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // The path to the documents directory. | |
| string sourceDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | |
| //Output directory | |
| string outputDir = RunExamples.Get_OutputDirectory(); | |
| // Instantiate a Workbook object | |
| // Open an Excel file | |
| Workbook workbook = new Workbook(sourceDir + "HyperlinksSample.xlsx"); | |
| // Get the first (default) worksheet | |
| Worksheet worksheet = workbook.Worksheets[0]; | |
| // Create a range A2:B3 | |
| Range range = worksheet.Cells.CreateRange("A2", "B3"); | |
| // Get Hyperlinks in range | |
| Hyperlink[] hyperlinks = range.Hyperlinks; | |
| foreach (Hyperlink link in hyperlinks) | |
| { | |
| Console.WriteLine(link.Area + " : " + link.Address); | |
| // To delete the link, use the Hyperlink.Delete() method. | |
| link.Delete(); | |
| } | |
| workbook.Save(outputDir + "HyperlinksSample_out.xlsx"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // The path to the documents directory. | |
| string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | |
| // Specify the file path | |
| string filePath = dataDir + "Book1.xlsx"; | |
| // Load a spreadsheet to be converted | |
| Workbook book = new Workbook(filePath); | |
| // Create an instance of HtmlSaveOptions | |
| HtmlSaveOptions saveOptions = new HtmlSaveOptions(SaveFormat.Html); | |
| // Set the ImageFormat to PNG | |
| saveOptions.ImageOptions.ImageType = Drawing.ImageType.Png; | |
| // Set SmoothingMode to AntiAlias | |
| saveOptions.ImageOptions.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; | |
| // Set TextRenderingHint to AntiAlias | |
| saveOptions.ImageOptions.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias; | |
| // Save spreadsheet to HTML while passing object of HtmlSaveOptions | |
| book.Save( dataDir + "output.html", saveOptions); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // The path to the documents directory. | |
| string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | |
| // Create a Stream object | |
| FileStream fstream = new FileStream(dataDir + "EncryptedBook1.xlsx", FileMode.Open); | |
| bool isPasswordValid = FileFormatUtil.VerifyPassword(fstream, "1234"); | |
| Console.WriteLine("Password is Valid: " + isPasswordValid); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| LoadOptions LoadOptions = new LoadOptions(); | |
| var objWB = new Aspose.Cells.Workbook(sourceDir + "Circular Formulas.xls", LoadOptions); | |
| objWB.Settings.Iteration = true; | |
| CalculationOptions copts = new CalculationOptions(); | |
| CircularMonitor cm = new CircularMonitor(); | |
| copts.CalculationMonitor = cm; | |
| objWB.CalculateFormula(copts); | |
| long lngCircularRef = cm.circulars.Count; | |
| Console.WriteLine("Circular References found - " + lngCircularRef); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| public class CircularMonitor : AbstractCalculationMonitor | |
| { | |
| public ArrayList circulars = new ArrayList(); | |
| public ArrayList Circulars { get { return circulars; } } | |
| public override bool OnCircular(IEnumerator circularCellsData) | |
| { | |
| CalculationCell cc = null; | |
| ArrayList cur = new ArrayList(); | |
| while (circularCellsData.MoveNext()) | |
| { | |
| cc = (CalculationCell)circularCellsData.Current; | |
| cur.Add(cc.Worksheet.Name + "!" + CellsHelper.CellIndexToName(cc.CellRow, cc.CellColumn)); | |
| } | |
| circulars.Add(cur); | |
| return true; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Create empty workbook | |
| Workbook workbook = new Workbook(); | |
| // Register macro enabled add-in along with the function name | |
| int id = workbook.Worksheets.RegisterAddInFunction(sourceDir + @"TESTUDF.xlam", "TEST_UDF", false); | |
| // Register more functions in the file (if any) | |
| workbook.Worksheets.RegisterAddInFunction(id, "TEST_UDF1"); //in this way you can add more functions that are in the same file | |
| // Access first worksheet | |
| Worksheet worksheet = workbook.Worksheets[0]; | |
| // Access first cell | |
| var cell = worksheet.Cells["A1"]; | |
| // Set formula name present in the add-in | |
| cell.Formula = "=TEST_UDF()"; | |
| // Save workbook to output XLSX format. | |
| workbook.Save(outputDir + @"test_udf.xlsx", Aspose.Cells.SaveFormat.Xlsx); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| //Load sample source file | |
| Workbook workbook = new Workbook(sourceDir + "Book1.xlsx"); | |
| HtmlSaveOptions options = new HtmlSaveOptions(); | |
| options.ExportHeadings = true; | |
| // Save the workbook | |
| workbook.Save(outputDir + "PrintHeadings_out.html", options); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| //Source directory | |
| string sourceDir = RunExamples.Get_SourceDirectory(); | |
| LoadOptions loadOptions = new LoadOptions(LoadFormat.CSV); | |
| // Load CSV file | |
| Workbook workbook = new Workbook(sourceDir + "SampleCsv.csv", loadOptions); | |
| Cell lastCell = workbook.Worksheets[0].Cells.LastCell; | |
| // Set ExportRangeToJsonOptions | |
| ExportRangeToJsonOptions options = new ExportRangeToJsonOptions(); | |
| Range range = workbook.Worksheets[0].Cells.CreateRange(0, 0, lastCell.Row + 1, lastCell.Column + 1); | |
| string data = JsonUtility.ExportRangeToJson(range, options); | |
| // Print JSON | |
| Console.WriteLine(data); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Open the template file | |
| Workbook workbook = new Workbook(sourceDir + "Book1.xlsx"); | |
| // Save as Markdown | |
| workbook.Save(outputDir + "Book1.docx", SaveFormat.Docx); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Open the template file | |
| Workbook workbook = new Workbook(sourceDir + "AddTooltipToHtmlSample.xlsx"); | |
| HtmlSaveOptions options = new HtmlSaveOptions(); | |
| options.AddTooltipText = true; | |
| // Save as Markdown | |
| workbook.Save(outputDir + "AddTooltipToHtmlSample_out.html", options); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Open the template file | |
| Workbook workbook = new Workbook(sourceDir + "Book1.xlsx"); | |
| // Save as Markdown | |
| workbook.Save(outputDir + "Book1.md", SaveFormat.Markdown); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Open the template file | |
| Workbook workbook = new Workbook(sourceDir + "Book1.xlsx"); | |
| // Save as Markdown | |
| workbook.Save(outputDir + "Book1.pptx", SaveFormat.Pptx); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| //Source directory | |
| string sourceDir = RunExamples.Get_SourceDirectory(); | |
| //Output directory | |
| string outputDir = RunExamples.Get_OutputDirectory(); | |
| // Read JSON file | |
| string str = File.ReadAllText(sourceDir + "SampleJson.json"); | |
| // Create empty workbook | |
| Workbook workbook = new Workbook(); | |
| // Get Cells | |
| Cells cells = workbook.Worksheets[0].Cells; | |
| // Set JsonLayoutOptions | |
| JsonLayoutOptions importOptions = new JsonLayoutOptions(); | |
| importOptions.ConvertNumericOrDate = true; | |
| importOptions.ArrayAsTable = true; | |
| importOptions.IgnoreArrayTitle = true; | |
| importOptions.IgnoreObjectTitle = true; | |
| JsonUtility.ImportData(str, cells, 0, 0, importOptions); | |
| // Save Workbook | |
| workbook.Save(outputDir + @"SampleJson_out.csv"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| //Source directory | |
| string sourceDir = RunExamples.Get_SourceDirectory(); | |
| //Output directory | |
| string outputDir = RunExamples.Get_OutputDirectory(); | |
| Workbook workbook = new Workbook(sourceDir + "PagesBook1.xlsx"); | |
| PdfSaveOptions pdfSaveOptions = new PdfSaveOptions(); | |
| pdfSaveOptions.PageSavingCallback = new TestPageSavingCallback(); | |
| workbook.Save(outputDir + "DocumentConversionProgress.pdf", pdfSaveOptions); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| public class TestPageSavingCallback : IPageSavingCallback | |
| { | |
| public void PageStartSaving(PageStartSavingArgs args) | |
| { | |
| Console.WriteLine("Start saving page index {0} of pages {1}", args.PageIndex, args.PageCount); | |
| //don't output pages before page index 2. | |
| if (args.PageIndex < 2) | |
| { | |
| args.IsToOutput = false; | |
| } | |
| } | |
| public void PageEndSaving(PageEndSavingArgs args) | |
| { | |
| Console.WriteLine("End saving page index {0} of pages {1}", args.PageIndex, args.PageCount); | |
| //don't output pages after page index 8. | |
| if (args.PageIndex >= 8) | |
| { | |
| args.HasMorePages = false; | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| //Source directory | |
| string sourceDir = RunExamples.Get_SourceDirectory(); | |
| //Output directory | |
| string outputDir = RunExamples.Get_OutputDirectory(); | |
| Workbook workbook = new Workbook(sourceDir + "sampleUseWorkbookRenderForImageConversion.xlsx"); | |
| ImageOrPrintOptions opts = new ImageOrPrintOptions(); | |
| opts.PageSavingCallback = new TestTiffPageSavingCallback(); | |
| opts.ImageType = ImageType.Tiff; | |
| WorkbookRender wr = new WorkbookRender(workbook, opts); | |
| wr.ToImage(outputDir + "DocumentConversionProgressForTiff_out.tiff"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| public class TestTiffPageSavingCallback : IPageSavingCallback | |
| { | |
| public void PageStartSaving(PageStartSavingArgs args) | |
| { | |
| Console.WriteLine("Start saving page index {0} of pages {1}", args.PageIndex, args.PageCount); | |
| //don't output pages before page index 2. | |
| if (args.PageIndex < 2) | |
| { | |
| args.IsToOutput = false; | |
| } | |
| } | |
| public void PageEndSaving(PageEndSavingArgs args) | |
| { | |
| Console.WriteLine("End saving page index {0} of pages {1}", args.PageIndex, args.PageCount); | |
| //don't output pages after page index 8. | |
| if (args.PageIndex >= 8) | |
| { | |
| args.HasMorePages = false; | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Load template file | |
| Workbook wb = new Workbook(sourceDir + "samplePivotTable.xlsx"); | |
| // Get first pivot table in the worksheet | |
| PivotTable pt = wb.Worksheets[1].PivotTables[0]; | |
| // Set pivot field | |
| pt.ShowReportFilterPage(pt.PageFields[0]); | |
| // Set position index for showing report filter pages | |
| pt.ShowReportFilterPageByIndex(pt.PageFields[0].Position); | |
| // Set the page field name | |
| pt.ShowReportFilterPageByName(pt.PageFields[0].Name); | |
| // Save the output file | |
| wb.Save(outputDir + "outputSamplePivotTable.xlsx"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| //Source directory | |
| string sourceDir = RunExamples.Get_SourceDirectory(); | |
| string outputDir = RunExamples.Get_OutputDirectory(); | |
| Workbook wb = new Workbook(sourceDir + "SamplePivotSort.xlsx"); | |
| // Obtaining the reference of the newly added worksheet | |
| Worksheet sheet = wb.Worksheets[0]; | |
| PivotTableCollection pivotTables = sheet.PivotTables; | |
| // source PivotTable | |
| // Adding a PivotTable to the worksheet | |
| int index = pivotTables.Add("=Sheet1!A1:C10", "E3", "PivotTable2"); | |
| //Accessing the instance of the newly added PivotTable | |
| PivotTable pivotTable = pivotTables[index]; | |
| // Unshowing grand totals for rows. | |
| pivotTable.RowGrand = false; | |
| pivotTable.ColumnGrand = false; | |
| // Dragging the first field to the row area. | |
| pivotTable.AddFieldToArea(PivotFieldType.Row, 1); | |
| PivotField rowField = pivotTable.RowFields[0]; | |
| rowField.IsAutoSort = true; | |
| rowField.IsAscendSort = true; | |
| // Dragging the second field to the column area. | |
| pivotTable.AddFieldToArea(PivotFieldType.Column, 0); | |
| PivotField colField = pivotTable.ColumnFields[0]; | |
| colField.NumberFormat = "dd/mm/yyyy"; | |
| colField.IsAutoSort = true; | |
| colField.IsAscendSort = true; | |
| // Dragging the third field to the data area. | |
| pivotTable.AddFieldToArea(PivotFieldType.Data, 2); | |
| pivotTable.RefreshData(); | |
| pivotTable.CalculateData(); | |
| // end of source PivotTable | |
| // sort the PivotTable on "SeaFood" row field values | |
| // Adding a PivotTable to the worksheet | |
| index = pivotTables.Add("=Sheet1!A1:C10", "E10", "PivotTable2"); | |
| // Accessing the instance of the newly added PivotTable | |
| pivotTable = pivotTables[index]; | |
| // Unshowing grand totals for rows. | |
| pivotTable.RowGrand = false; | |
| pivotTable.ColumnGrand = false; | |
| // Dragging the first field to the row area. | |
| pivotTable.AddFieldToArea(PivotFieldType.Row, 1); | |
| rowField = pivotTable.RowFields[0]; | |
| rowField.IsAutoSort = true; | |
| rowField.IsAscendSort = true; | |
| // Dragging the second field to the column area. | |
| pivotTable.AddFieldToArea(PivotFieldType.Column, 0); | |
| colField = pivotTable.ColumnFields[0]; | |
| colField.NumberFormat = "dd/mm/yyyy"; | |
| colField.IsAutoSort = true; | |
| colField.IsAscendSort = true; | |
| colField.AutoSortField = 0; | |
| //Dragging the third field to the data area. | |
| pivotTable.AddFieldToArea(PivotFieldType.Data, 2); | |
| pivotTable.RefreshData(); | |
| pivotTable.CalculateData(); | |
| // end of sort the PivotTable on "SeaFood" row field values | |
| // sort the PivotTable on "28/07/2000" column field values | |
| // Adding a PivotTable to the worksheet | |
| index = pivotTables.Add("=Sheet1!A1:C10", "E18", "PivotTable2"); | |
| // Accessing the instance of the newly added PivotTable | |
| pivotTable = pivotTables[index]; | |
| // Unshowing grand totals for rows. | |
| pivotTable.RowGrand = false; | |
| pivotTable.ColumnGrand = false; | |
| // Dragging the first field to the row area. | |
| pivotTable.AddFieldToArea(PivotFieldType.Row, 1); | |
| rowField = pivotTable.RowFields[0]; | |
| rowField.IsAutoSort = true; | |
| rowField.IsAscendSort = true; | |
| rowField.AutoSortField = 0; | |
| // Dragging the second field to the column area. | |
| pivotTable.AddFieldToArea(PivotFieldType.Column, 0); | |
| colField = pivotTable.ColumnFields[0]; | |
| colField.NumberFormat = "dd/mm/yyyy"; | |
| colField.IsAutoSort = true; | |
| colField.IsAscendSort = true; | |
| // Dragging the third field to the data area. | |
| pivotTable.AddFieldToArea(PivotFieldType.Data, 2); | |
| pivotTable.RefreshData(); | |
| pivotTable.CalculateData(); | |
| // end of sort the PivotTable on "28/07/2000" column field values | |
| //Saving the Excel file | |
| wb.Save(outputDir + "out_java.xlsx"); | |
| PdfSaveOptions options = new PdfSaveOptions(); | |
| options.OnePagePerSheet = true; | |
| wb.Save(outputDir + "out_java.pdf", options); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // directories | |
| string sourceDir = RunExamples.Get_SourceDirectory(); | |
| string outputDir = RunExamples.Get_OutputDirectory(); | |
| // Load a template file | |
| Workbook workbook = new Workbook(sourceDir + "PivotTableSample.xlsx"); | |
| // Get the first worksheet | |
| Worksheet worksheet = workbook.Worksheets[0]; | |
| int pivotIndex = 0; | |
| // Accessing the PivotTable | |
| PivotTable pivotTable = worksheet.PivotTables[pivotIndex]; | |
| // Accessing the data fields. | |
| PivotFieldCollection pivotFields = pivotTable.DataFields; | |
| // Accessing the first data field in the data fields. | |
| PivotField pivotField = pivotFields[0]; | |
| // Setting data display format | |
| pivotField.DataDisplayFormat = PivotFieldDataDisplayFormat.RankLargestToSmallest; | |
| pivotTable.CalculateData(); | |
| // Saving the Excel file | |
| workbook.Save(outputDir + "PivotTableDataDisplayFormatRanking_out.xlsx"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Source directory | |
| string sourceDir = RunExamples.Get_SourceDirectory(); | |
| // Load sample file | |
| Workbook workbook = new Workbook(sourceDir + "SamplePivotTableExternalConnection.xlsx"); | |
| Worksheet worksheet = workbook.Worksheets[0]; | |
| // Get the pivot table | |
| var pivotTable = worksheet.PivotTables[0]; | |
| // Print External Connection Details | |
| Console.WriteLine("External Connection Data Source"); | |
| Console.WriteLine("Name: " + pivotTable.ExternalConnectionDataSource.Name); | |
| Console.WriteLine("Type: " + pivotTable.ExternalConnectionDataSource.Type); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| string outputDir = RunExamples.Get_OutputDirectory(); | |
| // Instantiating a Workbook object | |
| Workbook workbook = new Workbook(); | |
| // Obtaining the reference of the newly added worksheet | |
| Worksheet sheet = workbook.Worksheets[0]; | |
| Cells cells = sheet.Cells; | |
| // Setting the value to the cells | |
| Cell cell = cells["A1"]; | |
| cell.PutValue("Sport"); | |
| cell = cells["B1"]; | |
| cell.PutValue("Quarter"); | |
| cell = cells["C1"]; | |
| cell.PutValue("Sales"); | |
| cell = cells["A2"]; | |
| cell.PutValue("Golf"); | |
| cell = cells["A3"]; | |
| cell.PutValue("Golf"); | |
| cell = cells["A4"]; | |
| cell.PutValue("Tennis"); | |
| cell = cells["A5"]; | |
| cell.PutValue("Tennis"); | |
| cell = cells["A6"]; | |
| cell.PutValue("Tennis"); | |
| cell = cells["A7"]; | |
| cell.PutValue("Tennis"); | |
| cell = cells["A8"]; | |
| cell.PutValue("Golf"); | |
| cell = cells["B2"]; | |
| cell.PutValue("Qtr3"); | |
| cell = cells["B3"]; | |
| cell.PutValue("Qtr4"); | |
| cell = cells["B4"]; | |
| cell.PutValue("Qtr3"); | |
| cell = cells["B5"]; | |
| cell.PutValue("Qtr4"); | |
| cell = cells["B6"]; | |
| cell.PutValue("Qtr3"); | |
| cell = cells["B7"]; | |
| cell.PutValue("Qtr4"); | |
| cell = cells["B8"]; | |
| cell.PutValue("Qtr3"); | |
| cell = cells["C2"]; | |
| cell.PutValue(1500); | |
| cell = cells["C3"]; | |
| cell.PutValue(2000); | |
| cell = cells["C4"]; | |
| cell.PutValue(600); | |
| cell = cells["C5"]; | |
| cell.PutValue(1500); | |
| cell = cells["C6"]; | |
| cell.PutValue(4070); | |
| cell = cells["C7"]; | |
| cell.PutValue(5000); | |
| cell = cells["C8"]; | |
| cell.PutValue(6430); | |
| PivotTableCollection pivotTables = sheet.PivotTables; | |
| // Adding a PivotTable to the worksheet | |
| int index = pivotTables.Add("=A1:C8", "E3", "PivotTable2"); | |
| // Accessing the instance of the newly added PivotTable | |
| PivotTable pivotTable = pivotTables[index]; | |
| // Unshowing grand totals for rows. | |
| pivotTable.RowGrand = false; | |
| // Draging the first field to the row area. | |
| pivotTable.AddFieldToArea(PivotFieldType.Row, 0); | |
| // Draging the second field to the column area. | |
| pivotTable.AddFieldToArea(PivotFieldType.Column, 1); | |
| // Draging the third field to the data area. | |
| pivotTable.AddFieldToArea(PivotFieldType.Data, 2); | |
| pivotTable.CalculateData(); | |
| // Saving the ODS file | |
| workbook.Save(outputDir + "PivotTableSaveInODS_out.ods"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // directories | |
| string sourceDir = RunExamples.Get_SourceDirectory(); | |
| string outputDir = RunExamples.Get_OutputDirectory(); | |
| Workbook workbook = new Workbook(sourceDir + "PivotTableHideAndSortSample.xlsx"); | |
| Worksheet worksheet = workbook.Worksheets[0]; | |
| var pivotTable = worksheet.PivotTables[0]; | |
| var dataBodyRange = pivotTable.DataBodyRange; | |
| int currentRow = 3; | |
| int rowsUsed = dataBodyRange.EndRow; | |
| // Sorting score in descending | |
| PivotField field = pivotTable.RowFields[0]; | |
| field.IsAutoSort = true; | |
| field.IsAscendSort = false; | |
| field.AutoSortField = 0; | |
| pivotTable.RefreshData(); | |
| pivotTable.CalculateData(); | |
| // Hiding rows with score less than 60 | |
| while (currentRow < rowsUsed) | |
| { | |
| Cell cell = worksheet.Cells[currentRow, 1]; | |
| double score = Convert.ToDouble(cell.Value); | |
| if (score < 60) | |
| { | |
| worksheet.Cells.HideRow(currentRow); | |
| } | |
| currentRow++; | |
| } | |
| pivotTable.RefreshData(); | |
| pivotTable.CalculateData(); | |
| // Saving the Excel file | |
| workbook.Save(outputDir + "PivotTableHideAndSort_out.xlsx"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| //Source directory | |
| string sourceDir = RunExamples.Get_SourceDirectory(); | |
| //Output directory | |
| string outputDir = RunExamples.Get_OutputDirectory(); | |
| // Create workbook from source file. | |
| Workbook workbook = new Workbook(sourceDir + "sampleExportRangeOfCellsInWorksheetToImage.xlsx"); | |
| // Access the first worksheet | |
| Worksheet worksheet = workbook.Worksheets[0]; | |
| // Set the print area with your desired range | |
| worksheet.PageSetup.PrintArea = "D8:G16"; | |
| // Set all margins as 0 | |
| worksheet.PageSetup.LeftMargin = 0; | |
| worksheet.PageSetup.RightMargin = 0; | |
| worksheet.PageSetup.TopMargin = 0; | |
| worksheet.PageSetup.BottomMargin = 0; | |
| // Set OnePagePerSheet option as true | |
| ImageOrPrintOptions options = new ImageOrPrintOptions(); | |
| options.OnePagePerSheet = true; | |
| options.ImageType = ImageType.Jpeg; | |
| options.HorizontalResolution = 200; | |
| options.VerticalResolution = 200; | |
| // Take the image of your worksheet | |
| SheetRender sr = new SheetRender(worksheet, options); | |
| sr.ToImage(0, outputDir + "outputExportRangeOfCellsInWorksheetToImage.jpg"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| //Output directory | |
| string outputDir = RunExamples.Get_OutputDirectory(); | |
| //Create workbook | |
| Workbook wb = new Workbook(); | |
| //Access first worksheet - it is empty sheet | |
| Worksheet ws = wb.Worksheets[0]; | |
| //Specify image or print options | |
| //Since the sheet is blank, we will set OutputBlankPageWhenNothingToPrint to true | |
| //So that empty page gets printed | |
| ImageOrPrintOptions opts = new ImageOrPrintOptions(); | |
| opts.ImageType = Drawing.ImageType.Png; | |
| opts.OutputBlankPageWhenNothingToPrint = true; | |
| //Render empty sheet to png image | |
| SheetRender sr = new SheetRender(ws, opts); | |
| sr.ToImage(0, outputDir + "OutputBlankPageWhenNothingToPrint.png"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| //Source directory | |
| string sourceDir = RunExamples.Get_SourceDirectory(); | |
| //Output directory | |
| string outputDir = RunExamples.Get_OutputDirectory(); | |
| //Load the sample Excel file | |
| Workbook wb = new Workbook(sourceDir + "sampleImageOrPrintOptions_PageIndexPageCount.xlsx"); | |
| //Access the first worksheet | |
| Worksheet ws = wb.Worksheets[0]; | |
| //Specify image or print options | |
| //We want to print pages 4, 5, 6, 7 | |
| ImageOrPrintOptions opts = new ImageOrPrintOptions(); | |
| opts.PageIndex = 3; | |
| opts.PageCount = 4; | |
| opts.ImageType = Drawing.ImageType.Png; | |
| //Create sheet render object | |
| SheetRender sr = new SheetRender(ws, opts); | |
| //Print all the pages as images | |
| for (int i = opts.PageIndex; i < sr.PageCount; i++) | |
| { | |
| sr.ToImage(i, outputDir + "outputImage-" + (i + 1) + ".png"); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Load template Excel file | |
| Workbook wb = new Workbook(sourceDir + "sampleCrosssType.xlsx"); | |
| // Create file streams for saving the PDF and PNG files | |
| using (FileStream outputStream = new FileStream(outputDir + "outputCrosssType.pdf", FileMode.Create)) | |
| using (FileStream outputStream2 = new FileStream(outputDir + "outputCrosssType.png", FileMode.Create)) | |
| { | |
| // Initialize PDF save options | |
| PdfSaveOptions saveOptions = new PdfSaveOptions(); | |
| // Set text cross type | |
| saveOptions.TextCrossType = TextCrossType.StrictInCell; | |
| // Save PDF file | |
| wb.Save(outputStream, saveOptions); | |
| // Initialize image or print options | |
| ImageOrPrintOptions imageSaveOptions = new ImageOrPrintOptions(); | |
| // Set text cross type | |
| imageSaveOptions.TextCrossType = TextCrossType.StrictInCell; | |
| // Initialize sheet renderer object | |
| SheetRender sheetRenderer = new SheetRender(wb.Worksheets[0], imageSaveOptions); | |
| // Create bitmap image from sheet renderer | |
| System.Drawing.Bitmap bitmap = sheetRenderer.ToImage(0); | |
| // Save PNG image | |
| bitmap.Save(outputStream2, ImageFormat.Png); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| //Output directory | |
| string outputDir = RunExamples.Get_OutputDirectory(); | |
| // Instantiate a new Workbook | |
| Workbook wb = new Workbook(); | |
| // Get the first (default) worksheet | |
| Worksheet _worksheet = wb.Worksheets[0]; | |
| // Create a range A1:B1 | |
| Range range = _worksheet.Cells.CreateRange(0, 0, 1, 2); | |
| // Merge the cells | |
| range.Merge(); | |
| // Insert value to the merged cell A1 | |
| _worksheet.Cells[0, 0].Value = "A quick brown fox jumps over the lazy dog. A quick brown fox jumps over the lazy dog....end"; | |
| // Create a style object | |
| Aspose.Cells.Style style = _worksheet.Cells[0, 0].GetStyle(); | |
| // Set wrapping text on | |
| style.IsTextWrapped = true; | |
| // Apply the style to the cell | |
| _worksheet.Cells[0, 0].SetStyle(style); | |
| // Create an object for AutoFitterOptions | |
| AutoFitterOptions options = new AutoFitterOptions(); | |
| // Set auto-fit for merged cells | |
| options.AutoFitMergedCellsType = AutoFitMergedCellsType.EachLine; | |
| // Autofit rows in the sheet(including the merged cells) | |
| _worksheet.AutoFitRows(options); | |
| // Save the Excel file | |
| wb.Save(outputDir + "AutofitRowsforMergedCells.xlsx"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| //Source directory | |
| string sourceDir = RunExamples.Get_SourceDirectory(); | |
| string outDir = RunExamples.Get_OutputDirectory(); | |
| //Load source Excel file | |
| Workbook workbook = new Workbook(sourceDir + "Book1.xlsx"); | |
| //Access first worksheet | |
| Worksheet worksheet = workbook.Worksheets[0]; | |
| // Set the width of the cell in pixels | |
| worksheet.Cells.SetViewColumnWidthPixel(7, 200); | |
| workbook.Save(outDir + "SetColumnViewWidthInPixels_Out.xlsx"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| //Source directory | |
| string sourceDir = RunExamples.Get_SourceDirectory(); | |
| string outDir = RunExamples.Get_OutputDirectory(); | |
| //Load source Excel file | |
| Workbook workbook = new Workbook(sourceDir + "Book1.xlsx"); | |
| //Access first worksheet | |
| Worksheet worksheet = workbook.Worksheets[0]; | |
| // Set the width of the column in pixels | |
| worksheet.Cells.SetColumnWidthPixel(7, 200); | |
| workbook.Save(outDir + "SetColumnWidthInPixels_Out.xlsx"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // The path to the documents directory. | |
| string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | |
| // Creating a file stream containing the Excel file to be opened | |
| FileStream fstream = new FileStream(dataDir + "book1.xls", FileMode.Open); | |
| // Instantiating a Workbook object | |
| // Opening the Excel file through the file stream | |
| Workbook workbook = new Workbook(fstream); | |
| // Accessing the first worksheet in the Excel file | |
| Worksheet worksheet = workbook.Worksheets[0]; | |
| // Setting Formatting options | |
| InsertOptions insertOptions = new InsertOptions(); | |
| insertOptions.CopyFormatType = CopyFormatType.SameAsAbove; | |
| // Inserting a row into the worksheet at 3rd position | |
| worksheet.Cells.InsertRows(2, 1, insertOptions); | |
| // Saving the modified Excel file | |
| workbook.Save(dataDir + "InsertingARowWithFormatting.out.xls"); | |
| // Closing the file stream to free all resources | |
| fstream.Close(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Load sample Excel file containing a table. | |
| Workbook workbook = new Workbook(sourceDir + "sampleCreateSlicerToExcelTable.xlsx"); | |
| // Access first worksheet. | |
| Worksheet worksheet = workbook.Worksheets[0]; | |
| // Access first table inside the worksheet. | |
| ListObject table = worksheet.ListObjects[0]; | |
| // Add slicer | |
| int idx = worksheet.Slicers.Add(table, 0, "H5"); | |
| Slicer slicer = worksheet.Slicers[idx]; | |
| slicer.Placement = PlacementType.FreeFloating; | |
| slicer.RowHeightPixel = 50; | |
| slicer.WidthPixel = 500; | |
| slicer.Title = "Aspose"; | |
| slicer.AlternativeText = "Alternate Text"; | |
| slicer.IsPrintable = false; | |
| slicer.IsLocked = false; | |
| // Refresh the slicer. | |
| slicer.Refresh(); | |
| // Save the workbook in output XLSX format. | |
| workbook.Save(outputDir + "outputChangeSlicerProperties.xlsx", SaveFormat.Xlsx); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Load sample Excel file containing a table. | |
| Workbook workbook = new Workbook(sourceDir + "sampleCreateSlicerToExcelTable.xlsx"); | |
| // Access first worksheet. | |
| Worksheet worksheet = workbook.Worksheets[0]; | |
| // Access first table inside the worksheet. | |
| ListObject table = worksheet.ListObjects[0]; | |
| // Add slicer | |
| int idx = worksheet.Slicers.Add(table, 0, "H5"); | |
| // Save the workbook in output XLSX format. | |
| workbook.Save(outputDir + "outputCreateSlicerToExcelTable.xlsx", SaveFormat.Xlsx); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| Workbook workbook = new Workbook(sourceDir + "SampleSlicerChart.xlsx"); | |
| workbook.Save(outputDir + "SampleSlicerChart.pdf", SaveFormat.Pdf); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | |
| Workbook workbook = new Workbook(); | |
| Style style = workbook.CreateStyle(); | |
| style.Pattern = BackgroundType.Solid; | |
| style.ForegroundColor = Color.Black; | |
| style.Font.Color = Color.White; | |
| // Create a designer workbook | |
| // Workbook workbook = new Workbook(); | |
| Worksheet worksheet = workbook.Worksheets[0]; | |
| worksheet.Cells["A1"].PutValue("Teacher Name"); | |
| worksheet.Cells["A1"].SetStyle(style); | |
| worksheet.Cells["A2"].PutValue("&=Teacher.Name"); | |
| worksheet.Cells["B1"].PutValue("Teacher Age"); | |
| worksheet.Cells["B1"].SetStyle(style); | |
| worksheet.Cells["B2"].PutValue("&=Teacher.Age"); | |
| worksheet.Cells["A3"].PutValue("Student Name"); | |
| worksheet.Cells["A3"].SetStyle(style); | |
| worksheet.Cells["A4"].PutValue("&=Teacher.Students.Name"); | |
| worksheet.Cells["B3"].PutValue("Student Age"); | |
| worksheet.Cells["B3"].SetStyle(style); | |
| worksheet.Cells["B4"].PutValue("&=Teacher.Students.Age"); | |
| worksheet.AutoFitColumns(); | |
| //A named range "_CellsSmartMarkers" must be added for checking which range contains all smart markers about a table. | |
| worksheet.Cells.CreateRange("1:4").Name = "_CellsSmartMarkers"; | |
| // Initialize WorkbookDesigner object | |
| WorkbookDesigner designer = new WorkbookDesigner(); | |
| // Load the template file | |
| designer.Workbook = workbook; | |
| System.Collections.Generic.List<Teacher> list = new System.Collections.Generic.List<Teacher>(); | |
| // Create an object for the Teacher class | |
| Teacher h1 = new Teacher("Mark John", 30); | |
| // Create the relevant student objects for the Teacher object | |
| h1.Students = new List<Person>(); | |
| h1.Students.Add(new Person("Chen Zhao", 14)); | |
| h1.Students.Add(new Person("Jamima Winfrey", 18)); | |
| h1.Students.Add(new Person("Reham Smith", 15)); | |
| // Create another object for the Teacher class | |
| Teacher h2 = new Teacher("Masood Shankar", 40); | |
| // Create the relevant student objects for the Teacher object | |
| h2.Students = new List<Person>(); | |
| h2.Students.Add(new Person("Karishma Jathool", 16)); | |
| h2.Students.Add(new Person("Angela Rose", 13)); | |
| h2.Students.Add(new Person("Hina Khanna", 15)); | |
| // Add the objects to the list | |
| list.Add(h1); | |
| list.Add(h2); | |
| // Specify the DataSource | |
| designer.SetDataSource("Teacher", list); | |
| designer.LineByLine = false; | |
| // Process the markers | |
| designer.Process(); | |
| // Autofit columns | |
| worksheet.AutoFitColumns(); | |
| // Save the Excel file. | |
| designer.Workbook.Save(dataDir + "output.xlsx"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| //Source directory | |
| string sourceDir = RunExamples.Get_SourceDirectory(); | |
| //Output directory | |
| string outputDir = RunExamples.Get_OutputDirectory(); | |
| // Open an existing file that contains a table/list object in it | |
| Workbook wb = new Workbook(sourceDir + "SampleTable.xlsx"); | |
| // Save the file | |
| wb.Save(outputDir + "ConvertTableToOds_out.ods"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // The path to the documents directory. | |
| string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | |
| // Open an existing file that contains a table/list object in it | |
| Workbook workbook = new Workbook(dataDir + "book1.xlsx"); | |
| TableToRangeOptions options = new TableToRangeOptions(); | |
| options.LastRow = 5; | |
| // Convert the first table/list object (from the first worksheet) to normal range | |
| workbook.Worksheets[0].ListObjects[0].ConvertToRange(options); | |
| // Save the file | |
| workbook.Save(dataDir + "output.xlsx"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // The path to the source directory. | |
| string sourceDir = RunExamples.Get_SourceDirectory(); | |
| string outputDir = RunExamples.Get_OutputDirectory(); | |
| // Load workbook object | |
| Workbook workbook = new Workbook(sourceDir + "SampleTableWithQueryTable.xls"); | |
| Worksheet worksheet = workbook.Worksheets[0]; | |
| ListObject table = worksheet.ListObjects[0]; | |
| // Check the data source type if it is query table | |
| if (table.DataSourceType == TableDataSourceType.QueryTable) | |
| { | |
| table.ShowTotals = true; | |
| } | |
| // Save the file | |
| workbook.Save(outputDir + "SampleTableWithQueryTable_out.xls"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| //Source directory | |
| string sourceDir = RunExamples.Get_SourceDirectory(); | |
| //Load sample Excel file | |
| Workbook workbook = new Workbook(sourceDir + "WebExtensionsSample.xlsx"); | |
| WebExtensionTaskPaneCollection taskPanes = workbook.Worksheets.WebExtensionTaskPanes; | |
| foreach (WebExtensionTaskPane taskPane in taskPanes) | |
| { | |
| Console.WriteLine("Width: " + taskPane.Width); | |
| Console.WriteLine("IsVisible: " + taskPane.IsVisible); | |
| Console.WriteLine("IsLocked: " + taskPane.IsLocked); | |
| Console.WriteLine("DockState: " + taskPane.DockState); | |
| Console.WriteLine("StoreName: " + taskPane.WebExtension.Reference.StoreName); | |
| Console.WriteLine("StoreType: " + taskPane.WebExtension.Reference.StoreType); | |
| Console.WriteLine("WebExtension.Id: " + taskPane.WebExtension.Id); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| //Source directory | |
| string outDir = RunExamples.Get_OutputDirectory(); | |
| Workbook workbook = new Workbook(); | |
| WebExtensionCollection extensions = workbook.Worksheets.WebExtensions; | |
| WebExtensionTaskPaneCollection taskPanes = workbook.Worksheets.WebExtensionTaskPanes; | |
| int extensionIndex = extensions.Add(); | |
| int taskPaneIndex = taskPanes.Add(); | |
| WebExtension extension = extensions[extensionIndex]; | |
| extension.Reference.Id = "wa104379955"; | |
| extension.Reference.StoreName = "en-US"; | |
| extension.Reference.StoreType = WebExtensionStoreType.OMEX; | |
| WebExtensionTaskPane taskPane = taskPanes[taskPaneIndex]; | |
| taskPane.IsVisible = true; | |
| taskPane.DockState = "right"; | |
| taskPane.WebExtension = extension; | |
| workbook.Save(outDir + "AddWebExtension_Out.xlsx"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| //Source directory | |
| string sourceDir = RunExamples.Get_SourceDirectory(); | |
| string outDir = RunExamples.Get_OutputDirectory(); | |
| Workbook workbook = new Workbook(sourceDir + "LargeSampleFile.xlsx"); | |
| XlsbSaveOptions options = new XlsbSaveOptions(); | |
| options.CompressionType = OoxmlCompressionType.Level1; | |
| var watch = System.Diagnostics.Stopwatch.StartNew(); | |
| workbook.Save(outDir + "LargeSampleFile_level_1_out.xlsb", options); | |
| watch.Stop(); | |
| var elapsedMs = watch.ElapsedMilliseconds; | |
| Console.WriteLine("Level 1 Elapsed Time: " + elapsedMs); | |
| watch = System.Diagnostics.Stopwatch.StartNew(); | |
| options.CompressionType = OoxmlCompressionType.Level6; | |
| workbook.Save(outDir + "LargeSampleFile_level_6_out.xlsb", options); | |
| watch.Stop(); | |
| elapsedMs = watch.ElapsedMilliseconds; | |
| Console.WriteLine("Level 6 Elapsed Time: " + elapsedMs); | |
| watch = System.Diagnostics.Stopwatch.StartNew(); | |
| options.CompressionType = OoxmlCompressionType.Level9; | |
| workbook.Save(outDir + "LargeSampleFile_level_9_out.xlsb", options); | |
| watch.Stop(); | |
| elapsedMs = watch.ElapsedMilliseconds; | |
| Console.WriteLine("Level 9 Elapsed Time: " + elapsedMs); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| //Source directory | |
| string sourceDir = RunExamples.Get_SourceDirectory(); | |
| string outputDir = RunExamples.Get_OutputDirectory(); | |
| // Instantiating a WorkbookDesigner object | |
| WorkbookDesigner designer = new WorkbookDesigner(); | |
| Workbook workbook = new Workbook(sourceDir + "AllowLeadingApostropheSample.xlsx"); | |
| workbook.Settings.QuotePrefixToStyle = false; | |
| // Open a designer spreadsheet containing smart markers | |
| designer.Workbook = workbook; | |
| List<DataObject> list = new List<DataObject> | |
| { | |
| new DataObject | |
| { | |
| Id =1, | |
| Name = "demo" | |
| }, | |
| new DataObject | |
| { | |
| Id=2, | |
| Name = "'demo" | |
| } | |
| }; | |
| // Set the data source for the designer spreadsheet | |
| designer.SetDataSource("sampleData", list); | |
| // Process the smart markers | |
| designer.Process(); | |
| designer.Workbook.Save(outputDir + "AllowLeadingApostropheSample_out.xlsx"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| internal class DataObject | |
| { | |
| public int Id { get; set; } | |
| public string Name { get; set; } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| //source directory | |
| string SourceDir = RunExamples.Get_SourceDirectory(); | |
| Workbook workbook = new Workbook(SourceDir + "LinkTypes.xlsx"); | |
| // Get the first (default) worksheet | |
| Worksheet worksheet = workbook.Worksheets[0]; | |
| // Create a range A2:B3 | |
| Range range = worksheet.Cells.CreateRange("A1", "A7"); | |
| // Get Hyperlinks in range | |
| Hyperlink[] hyperlinks = range.Hyperlinks; | |
| foreach (Hyperlink link in hyperlinks) | |
| { | |
| Console.WriteLine(link.TextToDisplay + ": " + link.LinkType); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| //directories | |
| string SourceDir = RunExamples.Get_SourceDirectory(); | |
| string outputDir = RunExamples.Get_OutputDirectory(); | |
| Workbook workbook = new Workbook(SourceDir + "EmbeddedMolSample.xlsx"); | |
| var index = 1; | |
| foreach (Worksheet sheet in workbook.Worksheets) | |
| { | |
| OleObjectCollection oles = sheet.OleObjects; | |
| foreach (var ole in oles) | |
| { | |
| string fileName = outputDir + "OleObject" + index + ".mol "; | |
| FileStream fs = File.Create(fileName); | |
| fs.Write(ole.ObjectData, 0, ole.ObjectData.Length); | |
| fs.Close(); | |
| index++; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // source directory | |
| string SourceDir = RunExamples.Get_SourceDirectory(); | |
| Workbook workbook = new Workbook(SourceDir + "ODataSample.xlsx"); | |
| PowerQueryFormulaCollction PQFcoll = workbook.DataMashup.PowerQueryFormulas; | |
| foreach (PowerQueryFormula PQF in PQFcoll) | |
| { | |
| Console.WriteLine("Connection Name: " + PQF.Name); | |
| PowerQueryFormulaItemCollection PQFIcoll = PQF.PowerQueryFormulaItems; | |
| foreach (PowerQueryFormulaItem PQFI in PQFIcoll) | |
| { | |
| Console.WriteLine("Name: " + PQFI.Name); | |
| Console.WriteLine("Value: " + PQFI.Value); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| //Source directory | |
| string sourceDir = RunExamples.Get_SourceDirectory(); | |
| string outputDir = RunExamples.Get_OutputDirectory(); | |
| CustomerList customers = new CustomerList(); | |
| customers.Add(new Customer("Thomas Hardy", "120 Hanover Sq., London")); | |
| customers.Add(new Customer("Paolo Accorti", "Via Monte Bianco 34, Torino")); | |
| Workbook workbook = new Workbook(sourceDir + "SmartMarker1.xlsx"); | |
| WorkbookDesigner designer = new WorkbookDesigner(workbook); | |
| designer.SetDataSource("Customer", new CustomerDataSource(customers)); | |
| designer.Process(); | |
| workbook.Save(outputDir + "dest.xlsx"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| public class CustomerDataSource : ICellsDataTable | |
| { | |
| public CustomerDataSource(CustomerList customers) | |
| { | |
| this.m_DataSource = customers; | |
| this.m_Properties = customers[0].GetType().GetProperties(); | |
| this.m_Columns = new string[this.m_Properties.Length]; | |
| this.m_PropHash = new Hashtable(this.m_Properties.Length); | |
| for (int i = 0; i < m_Properties.Length; i++) | |
| { | |
| this.m_Columns[i] = m_Properties[i].Name; | |
| this.m_PropHash.Add(m_Properties[i].Name, m_Properties[i]); | |
| } | |
| this.m_IEnumerator = this.m_DataSource.GetEnumerator(); | |
| } | |
| internal string[] m_Columns; | |
| internal ICollection m_DataSource; | |
| private Hashtable m_PropHash; | |
| private IEnumerator m_IEnumerator; | |
| private System.Reflection.PropertyInfo[] m_Properties; | |
| public string[] Columns | |
| { | |
| get | |
| { | |
| return this.m_Columns; | |
| } | |
| } | |
| public int Count | |
| { | |
| get | |
| { | |
| return this.m_DataSource.Count; | |
| } | |
| } | |
| public void BeforeFirst() | |
| { | |
| this.m_IEnumerator = this.m_DataSource.GetEnumerator(); | |
| } | |
| public object this[int index] | |
| { | |
| get | |
| { | |
| return this.m_Properties[index].GetValue(this.m_IEnumerator.Current, null); | |
| } | |
| } | |
| public object this[string columnName] | |
| { | |
| get | |
| { | |
| return ((System.Reflection.PropertyInfo)this.m_PropHash[columnName]).GetValue(this.m_IEnumerator.Current, null); | |
| } | |
| } | |
| public bool Next() | |
| { | |
| if (this.m_IEnumerator == null) | |
| return false; | |
| return this.m_IEnumerator.MoveNext(); | |
| } | |
| } | |
| public class Customer | |
| { | |
| public Customer(string aFullName, string anAddress) | |
| { | |
| FullName = aFullName; | |
| Address = anAddress; | |
| } | |
| public string FullName { get; set; } | |
| public string Address { get; set; } | |
| } | |
| public class CustomerList : ArrayList | |
| { | |
| public new Customer this[int index] | |
| { | |
| get { return (Customer)base[index]; } | |
| set { base[index] = value; } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| //Source directory | |
| string sourceDir = RunExamples.Get_SourceDirectory(); | |
| Workbook workbook = new Workbook(sourceDir + "Book1.xlsx"); | |
| ImageOrPrintOptions imgOptions = new ImageOrPrintOptions(); | |
| WorkbookPrintingPreview preview = new WorkbookPrintingPreview(workbook, imgOptions); | |
| Console.WriteLine("Workbook page count: " + preview.EvaluatedPageCount); | |
| SheetPrintingPreview preview2 = new SheetPrintingPreview(workbook.Worksheets[0], imgOptions); | |
| Console.WriteLine("Worksheet page count: " + preview2.EvaluatedPageCount); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| //Source directory | |
| string sourceDir = RunExamples.Get_SourceDirectory(); | |
| //Output directory | |
| string outputDir = RunExamples.Get_OutputDirectory(); | |
| Workbook workbook = new Workbook(sourceDir + "SampleRegexReplace.xlsx"); | |
| ReplaceOptions replace = new ReplaceOptions(); | |
| replace.CaseSensitive = false; | |
| replace.MatchEntireCellContents = false; | |
| // Set to true to indicate that the searched key is regex | |
| replace.RegexKey = true; | |
| workbook.Replace("\\bKIM\\b", "^^^TIM^^^", replace); | |
| workbook.Save(outputDir + "RegexReplace_out.xlsx"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Working directories | |
| string SourceDir = RunExamples.Get_SourceDirectory(); | |
| string outputDir = RunExamples.Get_OutputDirectory(); | |
| Workbook workbook = new Workbook(SourceDir + "SamplePowerQueryFormula.xlsx"); | |
| DataMashup mashupData = workbook.DataMashup; | |
| foreach (PowerQueryFormula formula in mashupData.PowerQueryFormulas) | |
| { | |
| foreach (PowerQueryFormulaItem item in formula.PowerQueryFormulaItems) | |
| { | |
| if (item.Name == "Source") | |
| { | |
| item.Value = "Excel.Workbook(File.Contents(\"" + SourceDir + "SamplePowerQueryFormulaSource.xlsx" + "\"), null, true)"; | |
| } | |
| } | |
| } | |
| // Save the output workbook. | |
| workbook.Save(outputDir + "SamplePowerQueryFormula_out.xlsx"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| //source directory | |
| string outputDir = RunExamples.Get_OutputDirectory(); | |
| Workbook workbook = new Workbook(FileFormatType.Xlsx); | |
| int index = workbook.ContentTypeProperties.Add("MK31", "Simple Data"); | |
| workbook.ContentTypeProperties[index].IsNillable = false; | |
| index = workbook.ContentTypeProperties.Add("MK32", DateTime.Now.ToString("yyyy-MM-dd'T'hh:mm:ss"), "DateTime"); | |
| workbook.ContentTypeProperties[index].IsNillable = true; | |
| workbook.Save(outputDir + "WorkingWithContentTypeProperties_out.xlsx"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| //Source directory | |
| string sourceDir = RunExamples.Get_SourceDirectory(); | |
| //Output directory | |
| string outputDir = RunExamples.Get_OutputDirectory(); | |
| Workbook workbook = new Workbook(sourceDir + "sourceFile.xlsx"); | |
| string password = "pfxPassword"; | |
| string pfx = "pfxFile"; | |
| DigitalSignature signature = new DigitalSignature(File.ReadAllBytes(pfx), password, "testXAdES", DateTime.Now); | |
| signature.XAdESType = XAdESType.XAdES; | |
| DigitalSignatureCollection dsCollection = new DigitalSignatureCollection(); | |
| dsCollection.Add(signature); | |
| workbook.SetDigitalSignature(dsCollection); | |
| workbook.Save(outputDir + "XAdESSignatureSupport_out.xlsx"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| class ControlExternalResourcesUsingWorkbookSetting_StreamProvider | |
| { | |
| //Source directory | |
| static string sourceDir = RunExamples.Get_SourceDirectory(); | |
| //Output directory | |
| static string outputDir = RunExamples.Get_OutputDirectory(); | |
| //Implementation of IStreamProvider | |
| class SP : IStreamProvider | |
| { | |
| public void CloseStream(StreamProviderOptions options) | |
| { | |
| } | |
| public void InitStream(StreamProviderOptions options) | |
| { | |
| //string sourceDir = RunExamples.Get_SourceDirectory(); | |
| //Open the filestream of Aspose Logo and assign it to StreamProviderOptions.Stream property | |
| FileStream fi = new FileStream(sourceDir + "sampleControlExternalResourcesUsingWorkbookSetting_StreamProvider.png", FileMode.OpenOrCreate, FileAccess.Read); | |
| options.Stream = fi; | |
| } | |
| } | |
| public static void Run() | |
| { | |
| //Load sample Excel file containing the external resource e.g. linked image etc. | |
| Workbook wb = new Workbook(sourceDir + "sampleControlExternalResourcesUsingWorkbookSetting_StreamProvider.xlsx"); | |
| //Provide your implementation of IStreamProvider | |
| wb.Settings.StreamProvider = new SP(); | |
| //Access first worksheet | |
| Worksheet ws = wb.Worksheets[0]; | |
| //Specify image or print options, we need one page per sheet and png output | |
| ImageOrPrintOptions opts = new ImageOrPrintOptions(); | |
| opts.OnePagePerSheet = true; | |
| opts.ImageType = Drawing.ImageType.Png; | |
| //Create sheet render by passing required parameters | |
| SheetRender sr = new SheetRender(ws, opts); | |
| //Convert your entire worksheet into png image | |
| sr.ToImage(0, outputDir + "outputControlExternalResourcesUsingWorkbookSetting_StreamProvider.png"); | |
| Console.WriteLine("ControlExternalResourcesUsingWorkbookSetting_StreamProvider executed successfully."); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| //Source directory | |
| string outDir = RunExamples.Get_OutputDirectory(); | |
| Workbook workbook = new Workbook(); | |
| // Add Author | |
| int authorIndex = workbook.Worksheets.ThreadedCommentAuthors.Add("Aspose Test", "", ""); | |
| ThreadedCommentAuthor author = workbook.Worksheets.ThreadedCommentAuthors[authorIndex]; | |
| // Add Threaded Comment | |
| workbook.Worksheets[0].Comments.AddThreadedComment("A1", "Test Threaded Comment", author); | |
| workbook.Save(outDir + "AddThreadedComments_out.xlsx"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| //Source directory | |
| string sourceDir = RunExamples.Get_SourceDirectory(); | |
| //Load source Excel file | |
| Workbook workbook = new Workbook(sourceDir + "BookWithSomeData.xlsx"); | |
| //Access first worksheet | |
| Worksheet worksheet = workbook.Worksheets[0]; | |
| //Print number of cell in the Worksheet | |
| Console.WriteLine("Number of Cells: " + worksheet.Cells.Count); | |
| // In the number of cells is greater than 2147483647, use CountLarge | |
| Console.WriteLine("Number of Cells (CountLarge): " + worksheet.Cells.CountLarge); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| //Source directory | |
| string outDir = RunExamples.Get_OutputDirectory(); | |
| Workbook workbook = new Workbook(); | |
| Worksheet worksheet = workbook.Worksheets[0]; | |
| worksheet.Cells[0, 2].Value = 1; | |
| worksheet.Cells[1, 2].Value = 2; | |
| worksheet.Cells[2, 2].Value = 3; | |
| worksheet.Cells[2, 3].Value = 4; | |
| worksheet.Cells.CreateRange(0, 2, 3, 1).Name = "NamedRange"; | |
| Range cut = worksheet.Cells.CreateRange("C:C"); | |
| worksheet.Cells.InsertCutCells(cut, 0, 1, ShiftType.Right); | |
| workbook.Save(outDir + "CutAndPasteCells.xlsx"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| //Source directory | |
| string sourceDir = RunExamples.Get_SourceDirectory(); | |
| //Load source Excel file | |
| Workbook workbook = new Workbook(sourceDir + "InternationalMacroSheet.xlsm"); | |
| //Get Sheet Type | |
| SheetType sheetType = workbook.Worksheets[0].Type; | |
| //Print Sheet Type | |
| Console.WriteLine("Sheet Type: " + sheetType); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| //Source directory | |
| string sourceDir = RunExamples.Get_SourceDirectory(); | |
| string outDir = RunExamples.Get_OutputDirectory(); | |
| Workbook workbook = new Workbook(sourceDir + "ThreadedCommentsSample.xlsx"); | |
| //Access first worksheet | |
| Worksheet worksheet = workbook.Worksheets[0]; | |
| // Get Threaded Comment | |
| ThreadedComment comment = worksheet.Comments.GetThreadedComments("A1")[0]; | |
| comment.Notes = "Updated Comment"; | |
| workbook.Save(outDir + "EditThreadedComments.xlsx"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| //Source directory | |
| string sourceDir = RunExamples.Get_SourceDirectory(); | |
| //Load source Excel file | |
| Workbook workbook = new Workbook(sourceDir + "SampleBook1.ods"); | |
| //Access first worksheet | |
| Worksheet worksheet = workbook.Worksheets[0]; | |
| Cell cell = worksheet.Cells["A9"]; | |
| if (cell.GetValidation() != null) | |
| { | |
| Console.WriteLine(cell.GetValidation().Type); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| //Source directory | |
| string sourceDir = RunExamples.Get_SourceDirectory(); | |
| //Load source Excel file | |
| Workbook workbook = new Workbook(sourceDir + "SampleExternalReferences.xlsx"); | |
| foreach (Name namedRange in workbook.Worksheets.Names) | |
| { | |
| ReferredArea[] referredAreas = namedRange.GetReferredAreas(true); | |
| if (referredAreas != null) | |
| { | |
| for (int i = 0; i < referredAreas.Length; i++) | |
| { | |
| ReferredArea referredArea = referredAreas[i]; | |
| // Print the data in Referred Area | |
| Console.WriteLine("IsExternalLink: " + referredArea.IsExternalLink); | |
| Console.WriteLine("IsArea: " + referredArea.IsArea); | |
| Console.WriteLine("SheetName: " + referredArea.SheetName); | |
| Console.WriteLine("ExternalFileName: " + referredArea.ExternalFileName); | |
| Console.WriteLine("StartColumn: " + referredArea.StartColumn); | |
| Console.WriteLine("StartRow: " + referredArea.StartRow); | |
| Console.WriteLine("EndColumn: " + referredArea.EndColumn); | |
| Console.WriteLine("EndRow: " + referredArea.EndRow); | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Source directory | |
| string sourceDir = RunExamples.Get_SourceDirectory(); | |
| // Load source Excel file | |
| Workbook workbook = new Workbook(sourceDir + "Book1.xlsx"); | |
| // Access first worksheet | |
| Worksheet worksheet = workbook.Worksheets[0]; | |
| // Print Unique Id | |
| Console.WriteLine("Unique Id: " + worksheet.UniqueId); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| //Source directory | |
| string sourceDir = RunExamples.Get_SourceDirectory(); | |
| //Load source Excel file | |
| Workbook workbook = new Workbook(sourceDir + "SheetRenderSample.xlsx"); | |
| ImageOrPrintOptions imgOpt = new ImageOrPrintOptions(); | |
| //Access first worksheet | |
| Worksheet worksheet = workbook.Worksheets[1]; | |
| SheetRender sheetRender = new SheetRender(worksheet, imgOpt); | |
| PrinterSettings printerSettings = new PrinterSettings(); | |
| printerSettings.PrinterName = "<PRINTER NAME>"; | |
| printerSettings.Copies = 2; | |
| sheetRender.ToPrinter(printerSettings); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| //Source directory | |
| string sourceDir = RunExamples.Get_SourceDirectory(); | |
| //Output directory | |
| string outputDir = RunExamples.Get_OutputDirectory(); | |
| //Load source Excel file | |
| Workbook workbook = new Workbook(sourceDir + "GraphicBackground.ods"); | |
| //Access first worksheet | |
| Worksheet worksheet = workbook.Worksheets[0]; | |
| OdsPageBackground background = worksheet.PageSetup.ODSPageBackground; | |
| Console.WriteLine("Background Type: " + background.Type.ToString()); | |
| Console.WriteLine("Backgorund Position: " + background.GraphicPositionType.ToString()); | |
| //Save background image | |
| Bitmap image = new Bitmap(new MemoryStream(background.GraphicData)); | |
| image.Save(outputDir + "background.jpg"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| //Source directory | |
| string sourceDir = RunExamples.Get_SourceDirectory(); | |
| Workbook workbook = new Workbook(sourceDir + "ThreadedCommentsSample.xlsx"); | |
| //Access first worksheet | |
| Worksheet worksheet = workbook.Worksheets[0]; | |
| // Get Threaded Comments | |
| ThreadedCommentCollection threadedComments = worksheet.Comments.GetThreadedComments("A1"); | |
| foreach (ThreadedComment comment in threadedComments) | |
| { | |
| Console.WriteLine("Comment: " + comment.Notes); | |
| Console.WriteLine("Author: " + comment.Author.Name); | |
| Console.WriteLine("Created Time: " + comment.CreatedTime); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| //Source directory | |
| string sourceDir = RunExamples.Get_SourceDirectory(); | |
| Workbook workbook = new Workbook(sourceDir + "ThreadedCommentsSample.xlsx"); | |
| //Access first worksheet | |
| Worksheet worksheet = workbook.Worksheets[0]; | |
| // Get Threaded Comments | |
| ThreadedCommentCollection threadedComments = worksheet.Comments.GetThreadedComments("A1"); | |
| foreach (ThreadedComment comment in threadedComments) | |
| { | |
| Console.WriteLine("Comment: " + comment.Notes); | |
| Console.WriteLine("Author: " + comment.Author.Name); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| //Source directory | |
| string sourceDir = RunExamples.Get_SourceDirectory(); | |
| string outDir = RunExamples.Get_OutputDirectory(); | |
| Workbook workbook = new Workbook(sourceDir + "ThreadedCommentsSample.xlsx"); | |
| //Access first worksheet | |
| Worksheet worksheet = workbook.Worksheets[0]; | |
| CommentCollection comments = worksheet.Comments; | |
| // Get Author of first comment in A1 | |
| ThreadedCommentAuthor author = worksheet.Comments.GetThreadedComments("A1")[0].Author; | |
| // Remove Comments | |
| comments.RemoveAt("A1"); | |
| ThreadedCommentAuthorCollection authors = workbook.Worksheets.ThreadedCommentAuthors; | |
| // Remove Author of first comment in A1 | |
| authors.RemoveAt(authors.IndexOf(author)); | |
| workbook.Save(outDir + "ThreadedCommentsSample_Out.xlsx"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| //Output directory | |
| string outputDir = RunExamples.Get_OutputDirectory(); | |
| // Instantiating a Workbook object | |
| Workbook workbook = new Workbook(); | |
| //Access first worksheet | |
| Worksheet worksheet = workbook.Worksheets[0]; | |
| worksheet.Cells[0, 0].Value = 1; | |
| worksheet.Cells[1, 0].Value = 2; | |
| worksheet.Cells[2, 0].Value = 3; | |
| worksheet.Cells[3, 0].Value = 4; | |
| worksheet.Cells[4, 0].Value = 5; | |
| worksheet.Cells[5, 0].Value = 6; | |
| worksheet.Cells[0, 1].Value = 7; | |
| worksheet.Cells[1, 1].Value = 8; | |
| worksheet.Cells[2, 1].Value = 9; | |
| worksheet.Cells[3, 1].Value = 10; | |
| worksheet.Cells[4, 1].Value = 11; | |
| worksheet.Cells[5, 1].Value = 12; | |
| OdsPageBackground background = worksheet.PageSetup.ODSPageBackground; | |
| background.Color = Color.Azure; | |
| background.Type = OdsPageBackgroundType.Color; | |
| workbook.Save(outputDir + "ColoredBackground.ods", SaveFormat.ODS); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| //Source directory | |
| string sourceDir = RunExamples.Get_SourceDirectory(); | |
| //Output directory | |
| string outputDir = RunExamples.Get_OutputDirectory(); | |
| // Instantiating a Workbook object | |
| Workbook workbook = new Workbook(); | |
| //Access first worksheet | |
| Worksheet worksheet = workbook.Worksheets[0]; | |
| worksheet.Cells[0, 0].Value = 1; | |
| worksheet.Cells[1, 0].Value = 2; | |
| worksheet.Cells[2, 0].Value = 3; | |
| worksheet.Cells[3, 0].Value = 4; | |
| worksheet.Cells[4, 0].Value = 5; | |
| worksheet.Cells[5, 0].Value = 6; | |
| worksheet.Cells[0, 1].Value = 7; | |
| worksheet.Cells[1, 1].Value = 8; | |
| worksheet.Cells[2, 1].Value = 9; | |
| worksheet.Cells[3, 1].Value = 10; | |
| worksheet.Cells[4, 1].Value = 11; | |
| worksheet.Cells[5, 1].Value = 12; | |
| OdsPageBackground background = worksheet.PageSetup.ODSPageBackground; | |
| background.Type = OdsPageBackgroundType.Graphic; | |
| background.GraphicData = File.ReadAllBytes(sourceDir + "background.jpg"); | |
| background.GraphicType = OdsPageBackgroundGraphicType.Area; | |
| workbook.Save(outputDir + "GraphicBackground.ods", SaveFormat.ODS); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| <script> | |
| function addComment() { | |
| gridwebinstance.getByIndex(0).addcomments({note:'hello',author:'aspose'}); | |
| } | |
| function removeComment() { | |
| gridwebinstance.getByIndex(0).delcomments(); | |
| } | |
| </script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| <script> | |
| function addLink() { | |
| var linkinfo={}; | |
| linkinfo.url="http://www.aspose.com", | |
| linkinfo.text="Link to Aspose Webbsite", | |
| gridwebinstance.getByIndex(0).rangeupdate(addCelllink,linkinfo); | |
| } | |
| function removeLink() { | |
| gridwebinstance.getByIndex(0).rangeupdate(delCelllink); | |
| } | |
| </script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| linkinfo.url="Sheet4!B8", | |
| linkinfo.text="link to sheet4 B8", | |
| linkinfo.targetsheetindex= 8, | |
| linkinfo.targetcellname="B8" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| <script> | |
| function makeFontItalic(){ | |
| gridwebinstance.getByIndex(0).rangeupdate(updateCellFontStyle, "i"); | |
| } | |
| function makeFontBold(){ | |
| gridwebinstance.getByIndex(0).rangeupdate(updateCellFontStyle, "b"); | |
| } | |
| function changeFontSize(){ | |
| gridwebinstance.getByIndex(0).rangeupdate(updateCellFontSize, "5pt"); | |
| } | |
| function changeFontFamily(){ | |
| gridwebinstance.getByIndex(0).rangeupdate(updateCellFontName, "Corbel Light"); | |
| } | |
| function changeFontColor(){ | |
| gridwebinstance.getByIndex(0).rangeupdate(updateCellFontColor, "green"); | |
| } | |
| function changeFontBackgroundColor(){ | |
| gridwebinstance.getByIndex(0).rangeupdate(updateCellBackGroundColor, "yellow"); | |
| } | |
| </script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class AcwController : Controller | |
| { | |
| public IActionResult Operation(string type, string id) | |
| { | |
| return Aspose.Cells.GridWeb.AcwController.DoAcwAction(this, type, id); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //set a session store path | |
| GridWeb.SessionStorePath = @"D:\Test\tmp\"; | |
| GridWeb mw = new GridWeb(); | |
| mw.ID = "gid"; | |
| mw.SetSession(HttpContext.Session); | |
| //set acw_client path | |
| mw.ResourceFilePath = "/js/acw_client/"; | |
| //load workbook | |
| mw.ImportExcelFile("D:\\Book1.xlsx"); | |
| //set width height | |
| mw.Width = Unit.Pixel(800); | |
| mw.Height = Unit.Pixel(500); | |
| return View(mw); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @model GridWeb | |
| <script src="~/js/acw_client/acwmain.js" asp-append-version="true"></script> | |
| <script src="~/js/acw_client/lang_en.js" asp-append-version="true"></script> | |
| <link href="~/js/acw_client/menu.css" rel="stylesheet" type="text/css"> | |
| <div class="text-center"> | |
| <GridWebDiv mw=Model></GridWebDiv> | |
| </div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| services.AddSession(options => | |
| { | |
| // Set a short timeout for easy testing. | |
| options.IdleTimeout = TimeSpan.FromSeconds(3600); | |
| options.Cookie.HttpOnly = true; | |
| // Make the session cookie essential | |
| options.Cookie.IsEssential = true; | |
| }); | |
| services.AddSingleton<Microsoft.Extensions.Hosting.IHostedService, GridScheduedService>(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| app.UseSession(); | |
| app.UseMvc(routes => | |
| { | |
| routes.MapRoute("acw", "acw/{type}/{id}", | |
| defaults: new { controller = "Acw", action = "Operation" }); | |
| routes.MapRoute( | |
| name: "default", | |
| template: "{controller=Home}/{action=Index}/{id?}"); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @using Aspose.Cells.GridWeb | |
| @addTagHelper *, Aspose.Cells.GridWeb |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //Specify the load options | |
| LoadOptions opts = new LoadOptions(); | |
| //We do not want to load defined names | |
| opts.LoadFilter = new LoadFilter(~LoadDataFilterOptions.DefinedNames); | |
| //Load the workbook | |
| Workbook wb = new Workbook(sourceDir + "sampleFilterDefinedNamesWhileLoadingWorkbook.xlsx", opts); | |
| //Save the output Excel file, it will break the formula in C1 | |
| wb.Save(outputDir + "outputFilterDefinedNamesWhileLoadingWorkbook.xlsx"); | |
| Console.WriteLine("FilterDefinedNamesWhileLoadingWorkbook executed successfully."); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| // Print message about XLS format. | |
| Console.WriteLine("Maximum Rows and Columns supported by XLS format."); | |
| // Create workbook in XLS format. | |
| Workbook wb = new Workbook(FileFormatType.Excel97To2003); | |
| // Print the maximum rows and columns supported by XLS format. | |
| int maxRows = wb.Settings.MaxRow + 1; | |
| int maxCols = wb.Settings.MaxColumn + 1; | |
| Console.WriteLine("Maximum Rows: " + maxRows); | |
| Console.WriteLine("Maximum Columns: " + maxCols); | |
| Console.WriteLine(); | |
| // Print message about XLSX format. | |
| Console.WriteLine("Maximum Rows and Columns supported by XLSX format."); | |
| // Create workbook in XLSX format. | |
| wb = new Workbook(FileFormatType.Xlsx); | |
| // Print the maximum rows and columns supported by XLSX format. | |
| maxRows = wb.Settings.MaxRow + 1; | |
| maxCols = wb.Settings.MaxColumn + 1; | |
| Console.WriteLine("Maximum Rows: " + maxRows); | |
| Console.WriteLine("Maximum Columns: " + maxCols); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
| //Load Excel file containing Dialog Sheet | |
| Workbook wb = new Workbook("sampleFindIfWorksheetIsDialogSheet.xlsx"); | |
| //Access first worksheet | |
| Worksheet ws = wb.Worksheets[0]; | |
| //Find if the sheet type is dialog and print the message | |
| if (ws.Type == SheetType.Dialog) | |
| { | |
| Console.WriteLine("Worksheet is a Dialog Sheet."); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment