Spire.Doc for Python 14.6.1 のリリースをお知らせいたします。本バージョンでは、文書処理とグラフ操作用の新しいインターフェースを複数追加しました。主な機能として、グラフの X 軸・Y 軸数値の取得、Word ファイルの XLSX 形式への直接出力、段落内への SmartArt グラフィックの挿入が可能になっています。 また、Word を PDF に変換する際に発生していた不具合についても正常に修正いたしました。詳細は以下をご参照ください。
変更内容一覧
| カテゴリー | ID | 説明 |
| 新機能 | - | CharacterFormat クラスに Kerning プロパティが追加され、文字のカーニング(字間調整)を設定できるようになりました。
textRange.CharacterFormat.Kerning = kerningValue |
| 新機能 | - | Chart クラスに X 軸データ値を取得するメソッド、ChartSeries クラスに Y 軸データ値を取得するメソッドが追加されました。
doc = Document()
doc.LoadFromFile(inputFile)
sb = []
number = 1
for i in range(doc.Sections.Count):
sec = doc.Sections.get_Item(i)
for j in range(sec.Paragraphs.Count):
paragraph = sec.Paragraphs.get_Item(j)
for k in range(paragraph.ChildObjects.Count):
obj = paragraph.ChildObjects[k]
if isinstance(obj, ShapeObject):
shape = obj
chart = shape.Chart
sb.append("\r\n\r\nPage " + str(number) + ":\r\n" + "Get all X-axis data:")
# X-axis
for x in range(chart.XValues.Count):
xVal = chart.XValues[x]
sb.append(str(xVal.StringValue) + " ")
# Y-axis of the first series
series = chart.Series[0]
sb.append("\r\nGet Y-axis data:")
for i in range(series.YValues.Count):
yVal = series.YValues.get_Item(i)
sb.append(str(yVal.Value) + " ")
number += 1
# Write to file
File.WriteAllText(outputFile, "".join(sb))
doc.Dispose() |
| 新機能 | - | ChartDataLabel クラス、ChartDataLabelCollection クラスの両方に Position プロパティが追加され、グラフのデータラベル位置を設定できるようになりました。
chart.Series[0].DataLabels.Position = position |
| 新機能 | - | CompareOptions クラスに複数の比較オプションプロパティが追加され、文書比較時に各種要素・書式変更を柔軟に無視できるようになりました。
doc1 = Document() doc1.LoadFromFile(inputFile_1) doc2 = Document() doc2.LoadFromFile(inputFile_2) options = CompareOptions() options = CompareOptions() options.IgnoreCaseChanges = True options.IgnoreComments = True options.IgnoreFields = True options.IgnoreFootnotes = True options.IgnoreTables = True options.IgnoreTextboxes = True doc1.Compare(doc2, "user", DateTime(), options) # 比較結果文書を保存 doc1.SaveToFile(outputFile, FileFormat.Docx2013) doc1.Close() doc2.Close() |
| 新機能 | - | Document クラスに GetRevisionInfos メソッドと RevisionsView プロパティが追加され、文書の変更履歴(リビジョン)情報の取得、および変更履歴の表示形式を制御できるようになりました。
doc = Document()
doc.LoadFromFile(inputFile)
revisionInfoCollection = doc.GetRevisionInfos()
sb = []
for revisionIndex in range(revisionInfoCollection.Count):
revisionInfo = revisionInfoCollection.get_Item(revisionIndex)
if revisionInfo.RevisionType == RevisionType.FormatChange:
if isinstance(revisionInfo.OwnerObject, TextRange):
text_range = revisionInfo.OwnerObject
sb.append("TextRange:" + text_range.Text + "\r\n")
doc.RevisionsView = RevisionsView.Original
sb.append("Original style: " + "isBold: " + str(text_range.CharacterFormat.Bold) + "; " + "TextColor: " + text_range.CharacterFormat.TextColor.ToString() + ", HighlightColor: " + text_range.CharacterFormat.HighlightColor.ToString() + ", FontName: " + str(text_range.CharacterFormat.FontName) + ", UnderlineStyle: " + str(text_range.CharacterFormat.UnderlineStyle) + "\r\n")
doc.RevisionsView = RevisionsView.Final
sb.append("Final style: " + "isBold: " + str(text_range.CharacterFormat.Bold) + "; " + "TextColor: " + text_range.CharacterFormat.TextColor.ToString() + ", HighlightColor: " + text_range.CharacterFormat.HighlightColor.ToString() + ", FontName: " + str(text_range.CharacterFormat.FontName) + ", UnderlineStyle: " + str(text_range.CharacterFormat.UnderlineStyle) + "\r\n")
File.WriteAllText(outputFile, "\n".join(sb))
doc.Close() |
| 新機能 | - | SaveToFile メソッドに新規パラメータが追加され、Word 文書を直接 XLSX 形式で保存できるようになりました。
document = Document() document.LoadFromFile(inputFile) document.SaveToFile(outputFile, FileFormat.XLSX) document.Close() |
| 新機能 | - | Document クラスに CompatibilityOptions プロパティが追加され、文書の互換性オプションを取得できるようになりました。
options = doc.CompatibilityOptions |
| 新機能 | - | Fill クラスに SetImage メソッドと FillType プロパティが追加され、塗りつぶし画像の設定と塗りつぶし種別の取得に対応しました。
node_new = smartArt.Nodes.Add()
node_new.Text = "Map"
shapeProperties = node_new.ShapeProperties[0]
# 図形の塗りつぶし種別を設定
shapeProperties.Fill.FillType = FillType.Picture
picFileStream = Stream("Image/0.jpg")
# 画像を設定
shapeProperties.Fill.SetImage(picFileStream) |
| 新機能 | - | Paragraph クラスに AppendSmartArt メソッドが追加され、段落内に SmartArt グラフィックを追加できるようになりました。
shape = paragraph.AppendSmartArt(SmartArtType.RepeatingBendingProcess, 432, 252) |
| 新機能 | - | ParagraphFormat クラスに AdjustRightIndent プロパティが追加され、段落の右インデントを自動調整するか否かを制御できるようになりました。
paragraph.Format.AdjustRightIndent = True |
| 新機能 | - | Shape クラスに HasSmartArt プロパティと SmartArt プロパティが追加され、図形に SmartArt が含まれるかの判定、および SmartArt オブジェクトの取得が可能になりました。
hasSmartArt=shape.HasSmartArt smartArt = shape.SmartArt |
| 新機能 | - | TableRow クラスに Hidden プロパティが追加され、表の行の非表示状態を設定・取得できるようになりました。
firstRow.Hidden = True |
| 新機能 | - | ToPdfParameterList クラスに GeneratorName プロパティが追加され、Word→PDF 変換時のジェネレーター名をカスタマイズできるようになりました。
doc = Document() toPdf = ToPdfParameterList() toPdf.GeneratorName = genName doc.LoadFromFile(inputFile) doc.SaveToFile(outputFile, toPdf) |
| 不具合修正 | SPIREDOC-11858 | Word を PDF に変換する際に「ArgNullReferenceException」例外が発生する不具合を修正しました。 |
リンクをクリックして Spire.Doc for Python 14.6.1 をダウンロードしてください:






