Spire.XLS for Java 4.11.3已发布。该版本增强了Excel到PDF的转换,并且修复了获取的日期格式单元格值错误等已知问题。详情请阅读以下内容。
问题修复:
在操作 Word 文档的过程中,有时会有一些重要信息需要保密,我们可以将它们隐藏以确保机密。本文展示如何使用 Spire.Doc for Java 在 Word 文档中隐藏特定段落。
首先,您需要在 Java 程序中添加 Spire.Doc.jar 文件作为依赖项。JAR 文件可以从 此链接 下载。 如果您使用 Maven,则可以将以下代码添加到项目的 pom.xml 文件中,从而轻松地在应用程序中导入 JAR 文件。
<repositories>
<repository>
<id>com.e-iceblue</id>
<name>e-iceblue</name>
<url>https://repo.e-iceblue.cn/repository/maven-public/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>e-iceblue</groupId>
<artifactId>spire.doc</artifactId>
<version>13.12.2</version>
</dependency>
</dependencies>
Spire.Doc for Java 支持使用 TextRange.getCharacterFormat().setHidden(boolean value) 方法来隐藏 Word 中的特定段落。以下是在 Word 中隐藏特定段落的详细步骤。
import com.spire.doc.*;
import com.spire.doc.documents.*;
import com.spire.doc.fields.*;
public class HideParagraph {
public static void main(String[] args) {
//创建document实例
Document document = new Document();
//加载示例Word文档
document.loadFromFile("http://cdn.e-iceblue.cn/C:\\Users\\Administrator\\Desktop\\sample.docx");
//获取第一节
Section sec = document.getSections().get(0);
//获取第一节中的第三段
Paragraph para;
para = sec.getParagraphs().get(2);
//循环遍历段落的子对象
for (Object docObj : para.getChildObjects()) {
DocumentObject obj = (DocumentObject)docObj;
//如果是子对象则将其转换为文本区域
if ((obj instanceof TextRange)) {
TextRange range = ((TextRange)(obj));
//隐藏文本区域
range.getCharacterFormat().setHidden(true);
}
}
//将文档保存为新文件
document.saveToFile("output/hideParagraph.docx", FileFormat.Docx_2013);
}
}
如果您希望删除结果文档中的评估消息,或者摆脱功能限制,请 该Email地址已收到反垃圾邮件插件保护。要显示它您需要在浏览器中启用JavaScript。 获取有效期 30 天的临时许可证。
Spire.Presentation 6.11.4已发布。该版本支持获取表格单元格边框的显示颜色,还增强了PowerPoint到图片,PowerPoint到PDF的转换。同时还修复了获取的文本字体大小不正确等已知问题。详情请阅读以下内容。
新功能:
table[0, 0].BorderLeftDisplayColor;
table[0, 0].BorderTopDisplayColor;
table[0, 0].BorderRightDisplayColor;
table[0, 0].BorderBottomDisplayColor;
问题修复:
https://www.e-iceblue.cn/Downloads/Spire-Presentation-NET.html
OFD(Open Fixed-layout Document 的简称,即开放式版式文档),是我国自主可控的电子文件格式。OFD 版式文件常用于电子文档发布、数字化信息传播和存档。前面我们介绍了将 PDF 文件格式转换为 OFD。 从 V9.11.3 开始,Spire.XLS for .NET 支持将 Excel 文件保存为 OFD 格式。本文将展示如何将 Excel 文件保存为 OFD 电子文件格式。
首先,您需要将 Spire.XLS for .NET 包含的 DLL 文件作为引用添加到您的 .NET 项目中。您可以从 下载页面 获取 dll文件,也可以通过 NuGet 安装。
PM> Install-Package Spire.XLS使用 Spire.XLS for .NET 来转换 Excel(以 .xlsx 格式为例)为 OFD 格式,只需要简单三行代码即可:
using Spire.Xls;
namespace ExceltoOFD
{
class Program
{
static void Main(string[] args)
{
//实例化Workbook类的对象
Workbook workbook = new Workbook();
//加载示例文档
workbook.LoadFromFile("Sample.xlsx");
//保存为OFD格式
workbook.SaveToFile("toOFD.OFD", FileFormat.OFD);
}
}
}Imports Spire.Xls
Namespace ExceltoOFD
Class Program
Private Shared Sub Main(ByVal args() As String)
'新建Workbook实例
Dim workbook As Workbook = New Workbook
'加载示例文档
workbook.LoadFromFile("Sample.xlsx")
'保存为OFD格式
workbook.SaveToFile("toOFD.OFD", FileFormat.OFD)
End Sub
End Class
End Namespace
如果您希望删除结果文档中的评估消息,或者摆脱功能限制,请 该Email地址已收到反垃圾邮件插件保护。要显示它您需要在浏览器中启用JavaScript。 获取有效期 30 天的临时许可证。
LaTeX 是一个强大的排版数学公式的工具,它支持多种数学符号来创建数学公式,如分数、积分、矩阵等。Spire.Presentation for .NET 提供了使用 LaTeX 代码创建并添加数学公式到 PowerPoint 幻灯片的方法,可供开发者创建多种类型的复杂公式,本文将对此做详细介绍。
首先,您需要将 Spire.Presentation for.NET 包含的 DLL 文件作为引用添加到您的 .NET 项目中。DLL 文件可以从 此链接 下载,也可以通过 NuGet 安装。
PM> Install-Package Spire.Presentation 下面是实现公式添加的详细步骤:
using Spire.Presentation;
using Spire.Presentation.Drawing;
using System.Drawing;
namespace AddFormula
{
class Program
{
static void Main(string[] args)
{
//定义LaTeX公式代码
string latexCode1 = @"x^{2} + \sqrt{x^{2}+1}=2";
string latexCode2 = @"F(x) &= \int^a_b \frac{1}{3}x^3";
string latexCode3 = @"\alpha + \beta \geq \gamma";
string latexCode4 = @"\overrightarrow{abc}";
string latexCode5 = @"\begin{bmatrix} 1 & 0 & \cdots & 0\\ 1 & 0 & \cdots & 0\\ \vdots & \vdots & \ddots & \vdots\\ 1 & 0 & 0 & 0 \end{bmatrix}";
string latexCode6 = @"\log_a{b}";
//创建Presentation类的实例
Presentation ppt = new Presentation();
//获取第一张幻灯片
ISlide slide = ppt.Slides[0];
//添加形状到幻灯片
IAutoShape shape = slide.Shapes.AppendShape(ShapeType.Rectangle, new RectangleF(30, 100, 200, 30));
shape.TextFrame.Paragraphs.Clear();
//使用LaTeX代码添加数学公式到形状
shape.TextFrame.Paragraphs.AddParagraphFromLatexMathCode(latexCode1);
//重复以上操作,添加形状,并添加公式到形状
shape = slide.Shapes.AppendShape(ShapeType.Rectangle, new RectangleF(240, 100, 200, 40));
shape.TextFrame.Paragraphs.Clear();
shape.TextFrame.Paragraphs.AddParagraphFromLatexMathCode(latexCode2);
shape = slide.Shapes.AppendShape(ShapeType.Rectangle, new RectangleF(30, 180, 200, 40));
shape.TextFrame.Paragraphs.Clear();
shape.TextFrame.Paragraphs.AddParagraphFromLatexMathCode(latexCode3);
shape = slide.Shapes.AppendShape(ShapeType.Rectangle, new RectangleF(240, 180, 200, 40));
shape.TextFrame.Paragraphs.Clear();
shape.TextFrame.Paragraphs.AddParagraphFromLatexMathCode(latexCode4);
shape = slide.Shapes.AppendShape(ShapeType.Rectangle, new RectangleF(30, 280, 200, 70));
shape.TextFrame.Paragraphs.Clear();
shape.TextFrame.Paragraphs.AddParagraphFromLatexMathCode(latexCode5);
shape = slide.Shapes.AppendShape(ShapeType.Rectangle, new RectangleF(240, 280, 200, 40));
shape.TextFrame.Paragraphs.Clear();
shape.TextFrame.Paragraphs.AddParagraphFromLatexMathCode(latexCode6);
//设置形状边框和填充类型
for (int i = 0; i < slide.Shapes.Count; i++)
{
slide.Shapes[i].Fill.FillType = FillFormatType.None;
slide.Shapes[i].Line.FillType = FillFormatType.None;
}
//保存文档
ppt.SaveToFile("MathEquations.pptx", FileFormat.Pptx2013);
}
}
}Imports Spire.Presentation
Imports Spire.Presentation.Drawing
Imports System.Drawing
Namespace AddFormula
Class Program
Private Shared Sub Main(args As String())
'定义LaTeX公式代码
Dim latexCode1 As String = "x^{2} + \sqrt{x^{2}+1}=2"
Dim latexCode2 As String = "F(x) &= \int^a_b \frac{1}{3}x^3"
Dim latexCode3 As String = "\alpha + \beta \geq \gamma"
Dim latexCode4 As String = "\overrightarrow{abc}"
Dim latexCode5 As String = "\begin{bmatrix} 1 & 0 & \cdots & 0\\ 1 & 0 & \cdots & 0\\ \vdots & \vdots & \ddots & \vdots\\ 1 & 0 & 0 & 0 \end{bmatrix}"
Dim latexCode6 As String = "\log_a{b}"
'创建Presentation类的实例
Dim ppt As New Presentation()
'获取第一张幻灯片
Dim slide As ISlide = ppt.Slides(0)
'添加形状到幻灯片
Dim shape As IAutoShape = slide.Shapes.AppendShape(ShapeType.Rectangle, New RectangleF(30, 100, 200, 30))
shape.TextFrame.Paragraphs.Clear()
'使用LaTeX代码添加数学公式到形状
shape.TextFrame.Paragraphs.AddParagraphFromLatexMathCode(latexCode1)
'重复以上操作,添加形状,并添加公式到形状
shape = slide.Shapes.AppendShape(ShapeType.Rectangle, New RectangleF(240, 100, 200, 40))
shape.TextFrame.Paragraphs.Clear()
shape.TextFrame.Paragraphs.AddParagraphFromLatexMathCode(latexCode2)
shape = slide.Shapes.AppendShape(ShapeType.Rectangle, New RectangleF(30, 180, 200, 40))
shape.TextFrame.Paragraphs.Clear()
shape.TextFrame.Paragraphs.AddParagraphFromLatexMathCode(latexCode3)
shape = slide.Shapes.AppendShape(ShapeType.Rectangle, New RectangleF(240, 180, 200, 40))
shape.TextFrame.Paragraphs.Clear()
shape.TextFrame.Paragraphs.AddParagraphFromLatexMathCode(latexCode4)
shape = slide.Shapes.AppendShape(ShapeType.Rectangle, New RectangleF(30, 280, 200, 70))
shape.TextFrame.Paragraphs.Clear()
shape.TextFrame.Paragraphs.AddParagraphFromLatexMathCode(latexCode5)
shape = slide.Shapes.AppendShape(ShapeType.Rectangle, New RectangleF(240, 280, 200, 40))
shape.TextFrame.Paragraphs.Clear()
shape.TextFrame.Paragraphs.AddParagraphFromLatexMathCode(latexCode6)
'设置形状边框和填充类型
For i As Integer = 0 To slide.Shapes.Count - 1
slide.Shapes(i).Fill.FillType = FillFormatType.None
slide.Shapes(i).Line.FillType = FillFormatType.None
Next
'保存文档
ppt.SaveToFile("MathEquations.pptx", FileFormat.Pptx2013)
End Sub
End Class
End Namespace公式添加效果:

如果您希望删除结果文档中的评估消息,或者摆脱功能限制,请 该Email地址已收到反垃圾邮件插件保护。要显示它您需要在浏览器中启用JavaScript。 获取有效期 30 天的临时许可证。
Spire.Email 4.11.1已发布。该版本修复了将PST文件中提取的电子邮件保存为eml格式时,发件人不正确的问题。详情请阅读以下内容。
问题修复:
Spire.Presentation for Java 4.11.4已发布。本次更新增强了PPT到HTML的转换功能,修复了无法获取幻灯片形状的问题。详情请阅读以下内容。
问题修复:
https://www.e-iceblue.cn/Downloads/Spire-Presentation-JAVA.html
将带有彩色图像的 PDF 转换为灰度可以帮助您减小文件大小,打印时无需消耗彩色墨水,从而节约打印成本。本篇文章将介绍如何使用 Spire.PDF for .NET 在 C# 和 VB.NET 中以编程的方式实现该转换。
首先,您需要添加 Spire.PDF for .NET 包中包含的 DLL 文件作为 .NET 项目中的引用。DLL 文件可以从 此链接 下载或通过 NuGet 安装。
PM> Install-Package Spire.PDF下面是将彩色PDF转换为灰度的步骤:
using Spire.Pdf.Conversion;
namespace ConvertPdfToGrayscale
{
class Program
{
static void Main(string[] args)
{
//创建一个PdfGrayConverter实例并加载文档
PdfGrayConverter converter = new PdfGrayConverter(@"Sample.pdf");
//将彩色PDF转换为灰度
converter.ToGrayPdf("Grayscale.pdf");
converter.Dispose();
}
}
}
Imports Spire.Pdf.Conversion
Namespace ConvertPdfToGrayscale
Friend Class Program
Private Shared Sub Main(ByVal args As String())
'创建一个PdfGrayConverter实例并加载文档
Dim converter As PdfGrayConverter = New PdfGrayConverter("Sample.pdf")
'将彩色PDF转换为灰度
converter.ToGrayPdf("Grayscale.pdf")
converter.Dispose()
End Sub
End Class
End Namespace原文档:

结果文档:

如果您希望删除结果文档中的评估消息,或者摆脱功能限制,请 该Email地址已收到反垃圾邮件插件保护。要显示它您需要在浏览器中启用JavaScript。 获取有效期 30 天的临时许可证。
Spire.Presentation 6.11.2已发布。本次更新支持获取表格单元格的填充颜色的功能,同时也支持设置图表数据标签的数据源的功能。此外,该版本还增强了转换PowerPoint到图片的功能,并且还修复了插入圆柱体等时出现的问题。详情请阅读以下内容。
新功能:
table.TableRows[i][j].DisplayColor;
Presentation ppt = new Presentation();
IChart chart = ppt.Slides[0].Shapes.AppendChart(ChartType.ColumnStacked, new RectangleF(100, 100, 500, 400));
CellRange cellRange = chart.ChartData["F1"];
cellRange.Text = "aaa";
cellRange = chart.ChartData["F2"];
cellRange.Text = "bbb";
cellRange = chart.ChartData["F3"];
cellRange.Text = "ccc";
cellRange = chart.ChartData["F4"];
cellRange.Text = "ddd";
chart.Series[0].DataLabelRanges = chart.ChartData["F1", "F4"];
ChartDataLabel dataLabel1 = chart.Series[0].DataLabels.Add();
dataLabel1.ID = 0;
dataLabel1.LabelValueVisible = true;
dataLabel1.ShowDataLabelsRange = true;
foreach (AnimationEffect effect in shape.Slide.Timeline.MainSequence)
{
if (effect.ShapeTarget.Equals(shape as Spire.Presentation.Shape))
{
MotionPath path = ((AnimationMotion)effect.CommonBehaviorCollection[0]).Path;
foreach (MotionCmdPath motionCmdPath in path)
{
PointF[] points = motionCmdPath.Points;
MotionCommandPathType type = motionCmdPath.CommandType;
}
}
}
Image image = shape.SaveAsImage();
问题修复:
https://www.e-iceblue.cn/Downloads/Spire-Presentation-NET.html
Spire.Doc 9.11.5已发布。该版本新增了SetColumnWidth方法设置表格列宽,以及新增UseNewEngine方法使用新引擎转换Word到PDF。此外还优化了调整设置表格单元格宽度的方法。详情请阅读以下内容。
新功能:
table.SetColumnWidth(int columnIndex, float columnWidth, CellWidthType columnWidthType);
Document doc = new Document();
doc.LoadFromFile("http://cdn.e-iceblue.cn/input.docx");
doc.UseNewEngine = true;
doc.SaveToFile("result.pdf", FileFormat.PDF);
问题修复:
//Old method
//tableCell.Width //Deprecated
//tableCell.CellWidthType //Deprecated
//New method
tableCell.SetCellWidth(float width, CellWidthType widthType);