翻译|产品更新|编辑:李显亮|2019-06-05 15:37:28.467|阅读 300 次
概述:Aspose.Words for .Net更新至v19.6版本,新增从Word文档中提取VBA宏的API,实现了表格样式的公共API,修复多项Bug。
# 慧都年终大促·界面/图表报表/文档/IDE等千款热门软控件火热促销中 >>
Aspose.Words for .NET是一种高级Word文档处理API,用于执行各种文档管理和操作任务。通过集成API,开发人员可以执行的一些基本任务,例如设计具有标准邮件合并字段的全功能Microsoft Word报告,几种常用格式之间的可靠转换,页面的高保真渲染,所有文档元素的格式化等等。
Aspose.Words for .Net更新至v19.6版本,新增从Word文档中提取VBA宏的API,实现了表格样式的公共API,修复多项Bug!
【点击下载最新版Aspose.Words for .Net】
key | 概述 | 类别 |
---|---|---|
WORDSNET-5312 | 支持创建表格样式 | 新功能 |
WORDSNET-17604 | 提供一种访问特定TableStyle的Cell Padding属性的方法 | 新功能 |
WORDSNET-18570 | 未识别水平合并单元格 | 新功能 |
WORDSNET-17757 | 提供API以从Word文档中提取VBA宏 | 新功能 |
WORDSNET-18400 | 添加功能以修改表格样式 | 新功能 |
WORDSNET-3714 | 考虑添加从文档中读取宏的功能 | 新功能 |
WORDSNET-18473 | 实现软件和硬件模式渲染之间的切换 | 新功能 |
WORDSNET-9641 | 访问表格样式的信息 | 新功能 |
WORDSNET-18372 | 调用Document.UpdateFields方法时发生System.NullReferenceException | Bug修复 |
WORDSNET-18556 | 渲染期间发生System.IndexOutOfRangeException | Bug修复 |
WORDSNET-18407 | Table.AutoFit不适用于AutoFitBehavior.AutoFitToWindow | Bug修复 |
WORDSNET-18566 | 将RTF转换为PDF后 - 缺少部分文本 | Bug修复 |
WORDSNET-16363 | SVG梯度问题 | Bug修复 |
• • • • • •
更多更新细则可参考【Aspose.Words for Java v19.5更新说明】
导出文档时始终会压缩大型元文件。但是由于性能原因,不会压缩小元文件。Word会压缩所有元文件,无论其大小如何。此外,其他一些文档编辑器(如LibreOffice)无法读取未压缩的元文件。为了允许用户选择适当的行为,DocSaveOptions类中引入了以下选项:
////// Whenfalse, small metafiles are not compressed for performance reason. /// Default value is true, all metafiles are compressed regardless of its size. ///public bool AlwaysCompressMetafiles
用例:
Document doc = new Document(@"sourse.doc"); DocSaveOptions saveOptions = new DocSaveOptions(); saveOptions.AlwaysCompressMetafiles = false; doc.Save("SmallMetafilesUncompressed.doc", saveOptions);
将出于安全原因删除此属性
////// Returns true if a valid license has been applied; false if the component is running in evaluation mode. ///[Obsolete("This property is obsolete. SetLicense() method raises an exception if license is invalid.")] public bool IsLicensed
实现了访问VBA项目源代码的功能。已添加以类:VbaProject,VbaModuleCollection,VbaModule。
////// Provides access to VBA project information. /// A VBA project inside the document is defined as a collection of VBA modules. ///public class VbaProject { ////// Returns VBA project name. ///public string Name { get; } ////// Returns collection of VBA project modules. ///public VbaModuleCollection Modules { get; } } ////// Provides access to VBA project module. ///public class VbaModule { ////// Returns VBA project module name. ///public string Name { get; } ////// Returns VBA project module source code. ///public string SourceCode { get; } }
用例:
Document doc = new Document(filename); if(doc.VbaModule != null) foreach(VbaModule module in doc.VbaProject.Modules) Console.WriteLine(module.SourceCode);
已从Range类中删除已废弃的方法Replace。并修复了新FindReplacer中的一些小错误。
////// Replaces all occurrences of a character pattern specified by a regular expression with another string. /////////Replaces the whole match captured by the regular expression.///Method is able to process breaks in both pattern and replacement strings./// You should use special meta-characters if you need to work with breaks: //////&p - paragraph break///&b - section break///&m - page break///&l - manual line break////// To leave any meta-character intact a parametershould be set to true. //////A regular expression pattern used to find matches.///A string to replace all occurrences of pattern.///object to specify additional options.///The number of replacements made.public int Replace(string pattern, string replacement) public int Replace(string pattern, string replacement, FindReplaceOptions options) public int Replace(Regex pattern, string replacement) public int Replace(Regex pattern, string replacement, FindReplaceOptions options)
新的公共属性已添加到TableStyle类中,并且已实现新的公共类型ConditionalStyleCollection,ConditionalStyle,ConditionalStyleType。
public class TableStyle : Style { // Gets or sets a flag indicating whether text in a table row is allowed to split across a page break. // The default value is true. public bool AllowBreakAcrossPages { get; set; } // Gets the collection of default cell borders for the style. public BorderCollection Borders { get; } // Gets or sets the amount of space (in points) to add to the left of the contents of table cells. public double LeftPadding { get; set; } // Gets or sets the amount of space (in points) to add to the right of the contents of table cells. public double RightPadding { get; set; } // Gets or sets the amount of space (in points) to add above the contents of table cells. public double TopPadding { get; set; } // Gets or sets the amount of space (in points) to add below the contents of table cells. public double BottomPadding { get; set; } // Specifies the alignment for the table style. // The default value is TableAlignment.Left. public TableAlignment Alignment { get; set; } // Gets or sets the amount of space (in points) between the cells. public double CellSpacing { get; set; } // Gets or sets whether this is a style for a right-to-left table. // When true, the cells in rows are laid out right to left. // The default value is false. public bool Bidi { get; set; } // Gets or sets the value that represents the left indent of a table. public double LeftIndent { get: set; } // Gets a Shading object that refers to the shading formatting for table cells. public Shading Shading { get; } // Gets or sets a number of rows to include in the banding when the style specifies odd/even row banding. public int RowStripe { get; set; } // Gets or sets a number of columns to include in the banding when the style specifies odd/even columns banding. public int ColumnStripe { get; set; } // Collection of conditional styles that may be defined for this table style. public ConditionalStyleCollection ConditionalStyles { get; } } // Represents a collection of ConditionalStyle objects. // It is not possible to add or remove items from this collection. It contains permanent set of items: one item for // each value of the ConditionalStyleType enumeration type. public class ConditionalStyleCollection : IEnumerable{ // Clears all conditional styles of the table style. public void ClearFormatting(); // Retrieves a ConditionalStyle object by conditional style type. public ConditionalStyle this[ConditionalStyleType conditionalStyleType] { get; } // Retrieves a ConditionalStyle object by index. // index: Zero-based index of the conditional style to retrieve. public ConditionalStyle this[int index] { get; } // Gets the number of conditional styles in the collection. public int Count { get; } // Gets the first row style. public ConditionalStyle FirstRow { get; } // Gets the first column style. public ConditionalStyle FirstColumn { get; } // Gets the last row style. public ConditionalStyle LastRow { get; } // Gets the last column style. public ConditionalStyle LastColumn { get; } // Gets the odd row banding style. public ConditionalStyle OddRowBanding { get; } // Gets the odd column banding style. public ConditionalStyle OddColumnBanding { get; } // Gets the even row banding style. public ConditionalStyle EvenRowBanding { get; } // Gets the even column banding style. public ConditionalStyle EvenColumnBanding { get; } // Gets the top left cell style. public ConditionalStyle TopLeftCell { get; } // Gets the top right cell style. public ConditionalStyle TopRightCell { get; } // Gets the bottom left cell style. public ConditionalStyle BottomLeftCell { get; } // Gets the bottom right cell style. public ConditionalStyle BottomRightCell { get; } } // Represents special formatting applied to some area of a table with assigned table style. public class ConditionalStyle { // Clears formatting of this conditional style. public void ClearFormatting(); // Gets the paragraph formatting of the conditional style. public ParagraphFormat ParagraphFormat { get: } // Gets the character formatting of the conditional style. public Font Font { get; } // Gets a Shading object that refers to the shading formatting for this conditional style. public Shading Shading { get; } // Gets the collection of default cell borders for the conditional style. public BorderCollection Borders { get; } // Gets or sets the amount of space (in points) to add to the left of the contents of table cells. public double LeftPadding { get; set; } // Gets or sets the amount of space (in points) to add to the right of the contents of table cells. public double RightPadding { get; set; } // Gets or sets the amount of space (in points) to add above the contents of table cells. public double TopPadding { get; set; } // Gets or sets the amount of space (in points) to add below the contents of table cells. public double BottomPadding { get; set; } // Gets table area to which this conditional style relates. public ConditionalStyleType Type { get; } } // Represents possible table areas to which conditional formatting may be defined in a table style. public enum ConditionalStyleType { // Specifies formatting of the first row of a table. FirstRow, // Specifies formatting of the first column of a table. FirstColumn, // Specifies formatting of the last row of a table. LastRow, // Specifies formatting of the last column of a table. LastColumn, // Specifies formatting of odd-numbered row stripe. OddRowBanding, // Specifies formatting of odd-numbered column stripe. OddColumnBanding, // Specifies formatting of even-numbered row stripe. EvenRowBanding, // Specifies formatting of even-numbered column stripe. EvenColumnBanding, // Specifies formatting of the top left cell of a table. TopLeftCell, // Specifies formatting of the top right cell of a table. TopRightCell, // Specifies formatting of the bottom left cell of a table. BottomLeftCell, // Specifies formatting of the bottom right cell of a table. BottomRightCell }
MS Word使用了两种众所周知的技术来实现表中的水平合并单元格。第一个是合并标志,如Cell.CellFormat。HorizontalMerge,但是根据最新的MS Word行为,似乎不再使用这种方式,而且MS Word只是不写merge标志。相反,MS Word使用了另一种技术,即单元格按其宽度水平合并。
因此,当单元格按其宽度水平合并时 - 没有合并标志,当然,没有办法使用合并标志来检测合并的单元格。一些客户发现这很不方便。为了解决这个不便,我们添加了一个新的公共方法,将通过其宽度水平合并的单元格转换为由flags水平合并的单元格。
用例:
Document doc = new Document(filename); Table table = doc.FirstSection.Body.Tables[0]; table.ConvertToHorizontallyMergedCells(); // Now merged cells have appropriate merge flags.
Aspose.Words现已加入20万+用户答谢惠,现在订购最高可省30000元!>>进入抢购通道
本站文章除注明转载外,均为本站原创或翻译。欢迎任何形式的转载,但请务必注明出处、不得修改原文相关链接,如果存在内容上的异议请邮件反馈至chenjj@capbkgr.cn