public void LoadEncryptedUsingStream() { //ExStart //ExFor:PlainTextDocument.#ctor(Stream, LoadOptions) //ExSummary:Shows how to load the contents of an encrypted Microsoft Word document in plaintext using stream. Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); builder.Writeln("Hello world!"); OoxmlSaveOptions saveOptions = new OoxmlSaveOptions(); saveOptions.Password = "******"; doc.Save(ArtifactsDir + "PlainTextDocument.LoadFromStreamWithOptions.docx", saveOptions); LoadOptions loadOptions = new LoadOptions(); loadOptions.Password = "******"; using (FileStream stream = new FileStream(ArtifactsDir + "PlainTextDocument.LoadFromStreamWithOptions.docx", FileMode.Open)) { PlainTextDocument plaintext = new PlainTextDocument(stream, loadOptions); Assert.AreEqual("Hello world!", plaintext.Text.Trim()); } //ExEnd }
public static void InsertShapeUsingDocumentBuilder(string dataDir) { // ExStart:InsertShapeUsingDocumentBuilder Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); //Free-floating shape insertion. Shape shape = builder.InsertShape(ShapeType.TextBox, RelativeHorizontalPosition.Page, 100, RelativeVerticalPosition.Page, 100, 50, 50, WrapType.None); shape.Rotation = 30.0; builder.Writeln(); //Inline shape insertion. shape = builder.InsertShape(ShapeType.TextBox, 50, 50); shape.Rotation = 30.0; OoxmlSaveOptions so = new OoxmlSaveOptions(SaveFormat.Docx); // "Strict" or "Transitional" compliance allows to save shape as DML. so.Compliance = OoxmlCompliance.Iso29500_2008_Transitional; dataDir = dataDir + "Shape_InsertShapeUsingDocumentBuilder_out.docx"; // Save the document to disk. doc.Save(dataDir, so); // ExEnd:InsertShapeUsingDocumentBuilder Console.WriteLine("\nInsert Shape successfully using DocumentBuilder.\nFile saved at " + dataDir); }
public void Iso29500Strict() { //ExStart //ExFor:OoxmlCompliance.Iso29500_2008_Strict //ExSummary:Shows conversion vml shapes to dml using Iso29500_2008_Strict option Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); //Set Word2003 version for document, for inserting image as vml shape doc.CompatibilityOptions.OptimizeFor(MsWordVersion.Word2003); Shape image = builder.InsertImage(MyDir + @"\Images\dotnet-logo.png"); // Loop through all single shapes inside document. foreach (Shape shape in doc.GetChildNodes(NodeType.Shape, true)) { Assert.AreEqual(ShapeMarkupLanguage.Vml, shape.MarkupLanguage); } OoxmlSaveOptions saveOptions = new OoxmlSaveOptions(); saveOptions.Compliance = OoxmlCompliance.Iso29500_2008_Strict; //Iso29500_2008 does not allow vml shapes, so you need to use OoxmlCompliance.Iso29500_2008_Strict for converting vml to dml shapes saveOptions.SaveFormat = SaveFormat.Docx; MemoryStream dstStream = new MemoryStream(); doc.Save(dstStream, saveOptions); //Assert that image have drawingML markup language foreach (Shape shape in doc.GetChildNodes(NodeType.Shape, true)) { Assert.AreEqual(ShapeMarkupLanguage.Dml, shape.MarkupLanguage); } //ExEnd }
public void Password() { //ExStart //ExFor:OoxmlSaveOptions.Password //ExSummary:Shows how to create a password protected Office Open XML document. Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); builder.Writeln("Hello world!"); // Create a SaveOptions object with a password and save our document with it OoxmlSaveOptions saveOptions = new OoxmlSaveOptions(); saveOptions.Password = "******"; doc.Save(ArtifactsDir + "OoxmlSaveOptions.Password.docx", saveOptions); // This document cannot be opened like a normal document Assert.Throws <IncorrectPasswordException>(() => doc = new Document(ArtifactsDir + "OoxmlSaveOptions.Password.docx")); // We can open the document and access its contents by passing the correct password to a LoadOptions object doc = new Document(ArtifactsDir + "OoxmlSaveOptions.Password.docx", new LoadOptions("MyPassword")); Assert.AreEqual("Hello world!", doc.GetText().Trim()); //ExEnd }
public void Password() { //ExStart //ExFor:OoxmlSaveOptions.Password //ExSummary:Shows how to create a password encrypted Office Open XML document. Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); builder.Writeln("Hello world!"); OoxmlSaveOptions saveOptions = new OoxmlSaveOptions(); saveOptions.Password = "******"; doc.Save(ArtifactsDir + "OoxmlSaveOptions.Password.docx", saveOptions); // We will not be able to open this document with Microsoft Word or // Aspose.Words without providing the correct password. Assert.Throws <IncorrectPasswordException>(() => doc = new Document(ArtifactsDir + "OoxmlSaveOptions.Password.docx")); // Open the encrypted document by passing the correct password in a LoadOptions object. doc = new Document(ArtifactsDir + "OoxmlSaveOptions.Password.docx", new LoadOptions("MyPassword")); Assert.AreEqual("Hello world!", doc.GetText().Trim()); //ExEnd }
public void Iso29500Strict() { //ExStart //ExFor:OoxmlCompliance.Iso29500_2008_Strict //ExSummary:Shows conversion vml shapes to dml using Iso29500_2008_Strict option Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); //Set Word2003 version for document, for inserting image as vml shape doc.CompatibilityOptions.OptimizeFor(MsWordVersion.Word2003); Shape image = builder.InsertImage(MyDir + @"dotnet-logo.png"); // Loop through all single shapes inside document. foreach (Shape shape in doc.GetChildNodes(NodeType.Shape, true)) { Assert.AreEqual(ShapeMarkupLanguage.Vml, shape.MarkupLanguage); } OoxmlSaveOptions saveOptions = new OoxmlSaveOptions(); saveOptions.Compliance = OoxmlCompliance.Iso29500_2008_Strict; //Iso29500_2008 does not allow vml shapes, so you need to use OoxmlCompliance.Iso29500_2008_Strict for converting vml to dml shapes saveOptions.SaveFormat = SaveFormat.Docx; MemoryStream dstStream = new MemoryStream(); doc.Save(dstStream, saveOptions); //Assert that image have drawingML markup language foreach (Shape shape in doc.GetChildNodes(NodeType.Shape, true)) { Assert.AreEqual(ShapeMarkupLanguage.Dml, shape.MarkupLanguage); } //ExEnd }
public void KeepLegacyControlChars(bool keepLegacyControlChars) { //ExStart //ExFor:OoxmlSaveOptions.KeepLegacyControlChars //ExFor:OoxmlSaveOptions.#ctor(SaveFormat) //ExSummary:Shows how to support legacy control characters when converting to .docx. Document doc = new Document(MyDir + "Legacy control character.doc"); // When we save the document to an OOXML format, we can create an OoxmlSaveOptions object // and then pass it to the document's saving method to modify how we save the document. // Set the "KeepLegacyControlChars" property to "true" to preserve // the "ShortDateTime" legacy character while saving. // Set the "KeepLegacyControlChars" property to "false" to remove // the "ShortDateTime" legacy character from the output document. OoxmlSaveOptions so = new OoxmlSaveOptions(SaveFormat.Docx); so.KeepLegacyControlChars = keepLegacyControlChars; doc.Save(ArtifactsDir + "OoxmlSaveOptions.KeepLegacyControlChars.docx", so); doc = new Document(ArtifactsDir + "OoxmlSaveOptions.KeepLegacyControlChars.docx"); Assert.AreEqual(keepLegacyControlChars ? "\u0013date \\@ \"MM/dd/yyyy\"\u0014\u0015\f" : "\u001e\f", doc.FirstSection.Body.GetText()); //ExEnd }
public void RestartListAtEachSection() { //ExStart:RestartListAtEachSection Document doc = new Document(); doc.Lists.Add(ListTemplate.NumberDefault); List list = doc.Lists[0]; list.IsRestartAtEachSection = true; DocumentBuilder builder = new DocumentBuilder(doc); builder.ListFormat.List = list; for (int i = 1; i < 45; i++) { builder.Writeln($"List Item {i}"); if (i == 15) { builder.InsertBreak(BreakType.SectionBreakNewPage); } } // IsRestartAtEachSection will be written only if compliance is higher then OoxmlComplianceCore.Ecma376. OoxmlSaveOptions options = new OoxmlSaveOptions { Compliance = OoxmlCompliance.Iso29500_2008_Transitional }; doc.Save(ArtifactsDir + "WorkingWithList.RestartListAtEachSection.docx", options); //ExEnd:RestartListAtEachSection }
public void LoadEncrypted() { //ExStart //ExFor:PlainTextDocument.#ctor(String, LoadOptions) //ExSummary:Shows how to load the contents of an encrypted Microsoft Word document in plaintext. Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); builder.Writeln("Hello world!"); OoxmlSaveOptions saveOptions = new OoxmlSaveOptions(); saveOptions.Password = "******"; doc.Save(ArtifactsDir + "PlainTextDocument.LoadEncrypted.docx", saveOptions); LoadOptions loadOptions = new LoadOptions(); loadOptions.Password = "******"; PlainTextDocument plaintext = new PlainTextDocument(ArtifactsDir + "PlainTextDocument.LoadEncrypted.docx", loadOptions); Assert.AreEqual("Hello world!", plaintext.Text.Trim()); //ExEnd }
public void KeepLegacyControlChars(bool doKeepLegacyControlChars) { //ExStart //ExFor:OoxmlSaveOptions.KeepLegacyControlChars //ExFor:OoxmlSaveOptions.#ctor(SaveFormat) //ExSummary:Shows how to support legacy control characters when converting to .docx. Document doc = new Document(MyDir + "Legacy control character.doc"); // Note that only one legacy character (ShortDateTime) is supported which declared in the "DOC" format OoxmlSaveOptions so = new OoxmlSaveOptions(SaveFormat.Docx); so.KeepLegacyControlChars = doKeepLegacyControlChars; doc.Save(ArtifactsDir + "OoxmlSaveOptions.KeepLegacyControlChars.docx", so); // Open the saved document and verify results doc = new Document(ArtifactsDir + "OoxmlSaveOptions.KeepLegacyControlChars.docx"); if (doKeepLegacyControlChars) { Assert.AreEqual("\u0013date \\@ \"MM/dd/yyyy\"\u0014\u0015\f", doc.FirstSection.Body.GetText()); } else { Assert.AreEqual("\u001e\f", doc.FirstSection.Body.GetText()); } //ExEnd }
public void UpdatingLastSavedTimeDocument() { //ExStart //ExFor:SaveOptions.UpdateLastSavedTimeProperty //ExSummary:Shows how to update a document time property when you want to save it. Document doc = new Document(MyDir + "Document.doc"); // Get last saved time DateTime documentTimeBeforeSave = doc.BuiltInDocumentProperties.LastSavedTime; OoxmlSaveOptions saveOptions = new OoxmlSaveOptions { UpdateLastSavedTimeProperty = true }; doc.Save(ArtifactsDir + "OoxmlSaveOptions.UpdatingLastSavedTimeDocument.docx", saveOptions); //ExEnd MemoryStream dstStream = new MemoryStream(); doc.Save(dstStream, saveOptions); DateTime documentTimeAfterSave = doc.BuiltInDocumentProperties.LastSavedTime; Assert.AreNotEqual(documentTimeBeforeSave, documentTimeAfterSave); }
private static ErrorMsg TryEncryptDocx(string filePath, string keyWord, string guid, VigenereEncryptor.Operation op, out string rawResult) { rawResult = null; //used for preview try { Document docx = new Document(filePath); VigenereEncryptor ve = new VigenereEncryptor(keyWord, op); for (int i = 1; i < docx.Sections[0].Body.Paragraphs.Count; i++) { string ciph = ve.Encrypt(docx.Sections[0].Body.Paragraphs[i].GetText()); docx.Sections[0].Body.Paragraphs[i].Runs[0].Text = ciph; if (ciph == null) { return(ErrorMsg.InvalidKeyWord); } rawResult += ciph + "\n"; } OoxmlSaveOptions opt = new OoxmlSaveOptions(SaveFormat.Docx); opt.Compliance = OoxmlCompliance.Ecma376_2006; docx.Save(WebApiApplication._ResultFilesDir + guid + ".docx", opt); } catch (Exception) { return(ErrorMsg.InvalidFileContent); } return(ErrorMsg.Ok); }
public void Iso29500Strict() { //ExStart //ExFor:OoxmlSaveOptions //ExFor:OoxmlSaveOptions.#ctor //ExFor:OoxmlSaveOptions.SaveFormat //ExFor:OoxmlCompliance //ExFor:OoxmlSaveOptions.Compliance //ExFor:ShapeMarkupLanguage //ExSummary:Shows conversion VML shapes to DML using ISO/IEC 29500:2008 Strict compliance level. Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); // Set Word2003 version for document, for inserting image as VML shape doc.CompatibilityOptions.OptimizeFor(MsWordVersion.Word2003); builder.InsertImage(ImageDir + "Transparent background logo.png"); Assert.AreEqual(ShapeMarkupLanguage.Vml, ((Shape)doc.GetChild(NodeType.Shape, 0, true)).MarkupLanguage); // Iso29500_2008 does not allow VML shapes // You need to use OoxmlCompliance.Iso29500_2008_Strict for converting VML to DML shapes OoxmlSaveOptions saveOptions = new OoxmlSaveOptions { Compliance = OoxmlCompliance.Iso29500_2008_Strict, SaveFormat = SaveFormat.Docx }; doc.Save(ArtifactsDir + "OoxmlSaveOptions.Iso29500Strict.docx", saveOptions); // The markup language of our shape has changed according to the compliance type doc = new Document(ArtifactsDir + "OoxmlSaveOptions.Iso29500Strict.docx"); Assert.AreEqual(ShapeMarkupLanguage.Dml, ((Shape)doc.GetChild(NodeType.Shape, 0, true)).MarkupLanguage); //ExEnd }
///<Summary> /// TextWatermark method to add text watermark ///</Summary> public Response TextWatermark(string fileName, string folderName, string watermarkText, string watermarkColor, string fontFamily = "Arial", double fontSize = 72, double textAngle = -45) { Opts.AppName = "Watermark"; Opts.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; Opts.FolderName = folderName; Opts.FileName = fileName; Opts.OutputType = "docx"; Opts.ResultFileName = Path.GetFileNameWithoutExtension(fileName) + " Text Watermark"; return(Process((inFilePath, outPath, zipOutFolder) => { var doc = new Document(Opts.WorkingFileName); if (string.IsNullOrEmpty(watermarkColor)) { watermarkColor = "#FF808080"; // Gray } var color = ColorTranslator.FromHtml(watermarkColor.StartsWith("#") ? watermarkColor : "#" + watermarkColor); var builder = new DocumentBuilder(doc); var watermark = builder.InsertShape(ShapeType.TextBox, 1, 1); // DML var run = new Run(doc, watermarkText) { Font = { Name = fontFamily, Color = color, Size = fontSize } }; var paragraph = new Paragraph(doc); paragraph.AppendChild(run); watermark.AppendChild(paragraph); watermark.TextBox.FitShapeToText = true; watermark.TextBox.TextBoxWrapMode = TextBoxWrapMode.None; watermark.TextBox.InternalMarginBottom = 0; watermark.TextBox.InternalMarginLeft = 0; watermark.TextBox.InternalMarginRight = 0; watermark.TextBox.InternalMarginTop = 0; watermark.Rotation = textAngle; watermark.RelativeHorizontalPosition = RelativeHorizontalPosition.Page; watermark.RelativeVerticalPosition = RelativeVerticalPosition.Page; watermark.WrapType = WrapType.None; watermark.VerticalAlignment = VerticalAlignment.Center; watermark.HorizontalAlignment = HorizontalAlignment.Center; watermark.ZOrder = -10000; // Appear behind other images watermark.BehindText = true; watermark.IsLayoutInCell = false; watermark.Stroked = false; watermark.Name = "WaterMark"; AddWatermark(doc, watermark); // Textbox must be saved as DML shape to enable rotation. So, OOXML compliance // must be "Transitional" or "Strict". var so = new OoxmlSaveOptions(SaveFormat.Docx) { Compliance = OoxmlCompliance.Iso29500_2008_Transitional }; doc.Save(outPath, so); })); }
public void EncryptDocxWithPassword() { //ExStart:EncryptDocxWithPassword Document doc = new Document(MyDir + "Document.docx"); OoxmlSaveOptions saveOptions = new OoxmlSaveOptions { Password = "******" }; doc.Save(ArtifactsDir + "WorkingWithOoxmlSaveOptions.EncryptDocxWithPassword.docx", saveOptions); //ExEnd:EncryptDocxWithPassword }
public static void EncryptDocxWithPassword(string dataDir) { //ExStart:EncryptDocxWithPassword Document doc = new Document(dataDir + "Document.doc"); OoxmlSaveOptions ooxmlSaveOptions = new OoxmlSaveOptions(); ooxmlSaveOptions.Password = "******"; dataDir = dataDir + "Document.Password_out.docx"; doc.Save(dataDir, ooxmlSaveOptions); //ExEnd:EncryptDocxWithPassword Console.WriteLine("\nThe password of document is set using ECMA376 Standard encryption algorithm.\nFile saved at " + dataDir); }
public void SetCompressionLevel() { // ExStart:SetCompressionLevel Document doc = new Document(MyDir + "Document.docx"); OoxmlSaveOptions saveOptions = new OoxmlSaveOptions { CompressionLevel = CompressionLevel.SuperFast }; doc.Save(ArtifactsDir + "WorkingWithOoxmlSaveOptions.SetCompressionLevel.docx", saveOptions); // ExEnd:SetCompressionLevel }
public void UpdateLastSavedTimeProperty() { //ExStart:UpdateLastSavedTimeProperty Document doc = new Document(MyDir + "Document.docx"); OoxmlSaveOptions saveOptions = new OoxmlSaveOptions { UpdateLastSavedTimeProperty = true }; doc.Save(ArtifactsDir + "WorkingWithOoxmlSaveOptions.UpdateLastSavedTimeProperty.docx", saveOptions); //ExEnd:UpdateLastSavedTimeProperty }
public void KeepLegacyControlChars() { //ExStart:KeepLegacyControlChars Document doc = new Document(MyDir + "Legacy control character.doc"); OoxmlSaveOptions saveOptions = new OoxmlSaveOptions(SaveFormat.FlatOpc) { KeepLegacyControlChars = true }; doc.Save(ArtifactsDir + "WorkingWithOoxmlSaveOptions.KeepLegacyControlChars.docx", saveOptions); //ExEnd:KeepLegacyControlChars }
public void DocumentCompression(CompressionLevel compressionLevel) { //ExStart //ExFor:OoxmlSaveOptions.CompressionLevel //ExFor:CompressionLevel //ExSummary:Shows how to specify the compression level to use while saving an OOXML document. Document doc = new Document(MyDir + "Images.docx"); // When we save the document to an OOXML format, we can create an OoxmlSaveOptions object // and then pass it to the document's saving method to modify how we save the document. // Set the "CompressionLevel" property to "CompressionLevel.Maximum" to apply the strongest and slowest compression. // Set the "CompressionLevel" property to "CompressionLevel.Normal" to apply // the default compression that Aspose.Words uses while saving OOXML documents. // Set the "CompressionLevel" property to "CompressionLevel.Fast" to apply a faster and weaker compression. // Set the "CompressionLevel" property to "CompressionLevel.SuperFast" to apply // the default compression that Microsoft Word uses. OoxmlSaveOptions saveOptions = new OoxmlSaveOptions(SaveFormat.Docx); saveOptions.CompressionLevel = compressionLevel; Stopwatch st = Stopwatch.StartNew(); doc.Save(ArtifactsDir + "OoxmlSaveOptions.docx", saveOptions); st.Stop(); FileInfo fileInfo = new FileInfo(ArtifactsDir + "OoxmlSaveOptions.docx"); Console.WriteLine($"Saving operation done using the \"{compressionLevel}\" compression level:"); Console.WriteLine($"\tDuration:\t{st.ElapsedMilliseconds} ms"); Console.WriteLine($"\tFile Size:\t{fileInfo.Length} bytes"); //ExEnd switch (compressionLevel) { case CompressionLevel.Maximum: Assert.That(1150000, Is.AtLeast(fileInfo.Length)); break; case CompressionLevel.Normal: Assert.That(1150000, Is.LessThan(fileInfo.Length)); break; case CompressionLevel.Fast: Assert.That(1200000, Is.LessThan(fileInfo.Length)); break; case CompressionLevel.SuperFast: Assert.That(1250000, Is.LessThan(fileInfo.Length)); break; } }
public static void Main() { // The path to the documents directory. string dataDir = Path.GetFullPath("../../../Data/"); //Specify your desired matrix int rowsCount = 10000; int colsCount = 30; var workbook = new Workbook(); var ooxmlSaveOptions = new OoxmlSaveOptions(); ooxmlSaveOptions.LightCellsDataProvider = new TestDataProvider(workbook, rowsCount, colsCount); workbook.Save(dataDir + "output.xlsx", ooxmlSaveOptions); }
public void CheckFileSignatures() { CompressionLevel[] compressionLevels = { CompressionLevel.Maximum, CompressionLevel.Normal, CompressionLevel.Fast, CompressionLevel.SuperFast }; #if JAVA string[] fileSignatures = new string[] { "50 4B 03 04 14 00 08 08 08 00 ", "50 4B 03 04 14 00 08 08 08 00 ", "50 4B 03 04 14 00 08 08 08 00 ", "50 4B 03 04 14 00 08 08 08 00 " }; #else string[] fileSignatures = { "50 4B 03 04 14 00 02 00 08 00 ", "50 4B 03 04 14 00 00 00 08 00 ", "50 4B 03 04 14 00 04 00 08 00 ", "50 4B 03 04 14 00 06 00 08 00 " }; #endif Document doc = new Document(); OoxmlSaveOptions saveOptions = new OoxmlSaveOptions(SaveFormat.Docx); long prevFileSize = 0; for (int i = 0; i < fileSignatures.Length; i++) { saveOptions.CompressionLevel = compressionLevels[i]; doc.Save(ArtifactsDir + "OoxmlSaveOptions.CheckFileSignatures.docx", saveOptions); using (MemoryStream stream = new MemoryStream()) using (FileStream outputFileStream = File.Open(ArtifactsDir + "OoxmlSaveOptions.CheckFileSignatures.docx", FileMode.Open)) { long fileSize = outputFileStream.Length; Assert.That(prevFileSize < fileSize); TestUtil.CopyStream(outputFileStream, stream); Assert.AreEqual(fileSignatures[i], TestUtil.DumpArray(stream.ToArray(), 0, 10)); prevFileSize = fileSize; } } }
public void ExportGeneratorName() { //ExStart //ExFor:SaveOptions.ExportGeneratorName //ExSummary:Shows how to disable adding name and version of Aspose.Words into produced files. Document doc = new Document(); // Use https://docs.aspose.com/words/net/generator-or-producer-name-included-in-output-documents/ to know how to check the result. OoxmlSaveOptions saveOptions = new OoxmlSaveOptions { ExportGeneratorName = false }; doc.Save(ArtifactsDir + "OoxmlSaveOptions.ExportGeneratorName.docx", saveOptions); //ExEnd }
public void OoxmlComplianceIso29500_2008_Strict() { //ExStart:OoxmlComplianceIso29500_2008_Strict Document doc = new Document(MyDir + "Document.docx"); doc.CompatibilityOptions.OptimizeFor(MsWordVersion.Word2016); OoxmlSaveOptions saveOptions = new OoxmlSaveOptions() { Compliance = OoxmlCompliance.Iso29500_2008_Strict }; doc.Save(ArtifactsDir + "WorkingWithOoxmlSaveOptions.OoxmlComplianceIso29500_2008_Strict.docx", saveOptions); //ExEnd:OoxmlComplianceIso29500_2008_Strict }
public void KeepLegacyControlChars() { //ExStart //ExFor:OoxmlSaveOptions.KeepLegacyControlChars //ExSummary:Shows how to support legacy control characters when converting to .docx Document doc = new Document(MyDir + "OoxmlSaveOptions.KeepLegacyControlChars.doc"); // Note that only one legacy character (ShortDateTime) is supported which declared in the "DOC" format OoxmlSaveOptions so = new OoxmlSaveOptions(); so.KeepLegacyControlChars = true; doc.Save(ArtifactsDir + "OoxmlSaveOptions.KeepLegacyControlChars.docx", so); //ExEnd }
public static void SetCompressionLevel(string dataDir) { // ExStart:SetCompressionLevel Document doc = new Document(dataDir + "Document.doc"); OoxmlSaveOptions so = new OoxmlSaveOptions(SaveFormat.Docx); so.CompressionLevel = CompressionLevel.SuperFast; // Save the document to disk. doc.Save(dataDir + "SetCompressionLevel_out.docx", so); // ExEnd:SetCompressionLevel Console.WriteLine("\nDocument save with a Compression Level Successfully.\nFile saved at " + dataDir); doc.Save("out.docx", so); }
public static void UpdateLastSavedTimeProperty(String dataDir) { // ExStart:UpdateLastSavedTimeProperty Document doc = new Document(dataDir + "Document.doc"); OoxmlSaveOptions ooxmlSaveOptions = new OoxmlSaveOptions(); ooxmlSaveOptions.UpdateLastSavedTimeProperty = true; dataDir = dataDir + "UpdateLastSavedTimeProperty_out.docx"; // Save the document to disk. doc.Save(dataDir, ooxmlSaveOptions); // ExEnd:UpdateLastSavedTimeProperty Console.WriteLine("\nUpdated Last Saved Time Property successfully.\nFile saved at " + dataDir); }
public static void KeepLegacyControlChars(String dataDir) { // ExStart:KeepLegacyControlChars Document doc = new Document(dataDir + "Document.doc"); OoxmlSaveOptions so = new OoxmlSaveOptions(SaveFormat.FlatOpc); so.KeepLegacyControlChars = true; dataDir = dataDir + "Document_out.docx"; // Save the document to disk. doc.Save(dataDir, so); // ExEnd:KeepLegacyControlChars Console.WriteLine("\nUpdated Last Saved With Keeping Legacy Control Chars Successfully.\nFile saved at " + dataDir); }
public static void Run() { // The path to the documents directory. string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); // Specify your desired matrix int rowsCount = 10000; int colsCount = 30; var workbook = new Workbook(); var ooxmlSaveOptions = new OoxmlSaveOptions(); ooxmlSaveOptions.LightCellsDataProvider = new TestDataProvider(workbook, rowsCount, colsCount); workbook.Save(dataDir + "output.out.xlsx", ooxmlSaveOptions); }
public static void Main() { // The path to the documents directory. string dataDir = Path.GetFullPath("../../../Data/"); //Specify your desired matrix int rowsCount = 10000; int colsCount = 30; var workbook = new Workbook(); var ooxmlSaveOptions = new OoxmlSaveOptions(); ooxmlSaveOptions.LightCellsDataProvider = new TestDataProvider(workbook, rowsCount, colsCount); workbook.Save(dataDir+ "output.xlsx", ooxmlSaveOptions); }
public static void Main() { // The path to the documents directory. string dataDir = Aspose.Cells.Examples.Utils.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); //Specify your desired matrix int rowsCount = 10000; int colsCount = 30; var workbook = new Workbook(); var ooxmlSaveOptions = new OoxmlSaveOptions(); ooxmlSaveOptions.LightCellsDataProvider = new TestDataProvider(workbook, rowsCount, colsCount); workbook.Save(dataDir + "output.out.xlsx", ooxmlSaveOptions); }
public void AddCornersSnipped() { //ExStart:AddCornersSnipped Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); builder.InsertShape(ShapeType.TopCornersSnipped, 50, 50); OoxmlSaveOptions saveOptions = new OoxmlSaveOptions(SaveFormat.Docx) { Compliance = OoxmlCompliance.Iso29500_2008_Transitional }; doc.Save(ArtifactsDir + "WorkingWithShapes.AddCornersSnipped.docx", saveOptions); //ExEnd:AddCornersSnipped }
public static void AddCornersSnipped(string dataDir) { // ExStart:AddCornersSnipped Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); Shape shape = builder.InsertShape(ShapeType.TopCornersSnipped, 50, 50); OoxmlSaveOptions so = new OoxmlSaveOptions(SaveFormat.Docx); so.Compliance = OoxmlCompliance.Iso29500_2008_Transitional; dataDir = dataDir + "AddCornersSnipped_out.docx"; //Save the document to disk. doc.Save(dataDir, so); // ExEnd:AddCornersSnipped Console.WriteLine("\nCorner Snip shape is created successfully.\nFile saved at " + dataDir); }