Spire.Doc 11.5.6のリリースを発表できることを嬉しく思います。このリリースでは、グラフやSVGドキュメントを追加する機能がサポートされています。また、1ページに複数ページを印刷する機能もサポートされています。ページの内容や内容の座標を取得するなど、ページを操作する機能もサポートされています。詳細は以下の内容を読んでください。
このリリースで行われた変更のリストは次のとおりです
| カテゴリー | ID | 説明 |
| New feature | - | グラフを追加する機能がサポートされています。
//Documentを作成する
Document document = new Document();
//新しいセクションを作成する
Section section = document.AddSection();
//新しい段落を作成してテキストを追加する
section.AddParagraph().AppendText("Column chart.");
//新しい段落を作成してカラムグラフを追加する
Paragraph newPara = section.AddParagraph();
ShapeObject shape = newPara.AppendChart(ChartType.Column, 500, 300);
//グラフのシリーズデータを消去して、新しいグラフで始める
Chart chart = shape.Chart;
chart.Series.Clear();
//カスタム・シリーズをグラフに追加します。X軸はカテゴリ、Y軸は対応する大きな数値です
chart.Series.Add("Test Series",
new[] { "Word", "PDF", "Excel", "GoogleDocs", "Office" },
new double[] { 1900000, 850000, 2100000, 600000, 1500000 });
//Y軸スケールラベルの数値フォーマットをカンマで数値をグループ化するように設定する
chart.AxisY.NumberFormat.FormatCode = "#,##0";
//docxファイルに保存する
document.SaveToFile("AppendColumnChart.docx", FileFormat.Docx);//Documentを作成する
Document document = new Document();
//新しいセクションを作成する
Section section = document.AddSection();
//新しい段落を作成してテキストを追加する
section.AddParagraph().AppendText("Bubble chart.");
//新しい段落を作成してバブルグラフを追加する
Paragraph newPara = section.AddParagraph();
ShapeObject shape = newPara.AppendChart(ChartType.Bubble, 500, 300);
//グラフのシリーズデータを消去して、新しいグラフで始める
Chart chart = shape.Chart;
chart.Series.Clear();
//X/Y座標と各気泡直径を持つカスタムシリーズを追加する
ChartSeries series = chart.Series.Add("Test Series",
new[] { 2.9, 3.5, 1.1, 4.0, 4.0 },
new[] { 1.9, 8.5, 2.1, 6.0, 1.5 },
new[] { 9.0, 4.5, 2.5, 8.0, 5.0 });
//docxファイルに保存する
document.SaveToFile("AppendBubbleChart.docx", FileFormat.Docx);//Documentを作成する
Document document = new Document();
//新しいセクションを作成する
Section section = document.AddSection();
//新しい段落を作成してテキストを追加する
section.AddParagraph().AppendText("Line chart.");
//新しい段落を作成して折れ線グラフを追加する
Paragraph newPara = section.AddParagraph();
ShapeObject shape = newPara.AppendChart(ChartType.Line, 500, 300);
//グラフのシリーズデータを消去して、新しいグラフで始める
Chart chart = shape.Chart;
ChartTitle title = chart.Title;
title.Text = "My Chart";
ChartSeriesCollection seriesColl = chart.Series;
seriesColl.Clear();
//新しいデータをグラフに設定
string[] categories = { "C1", "C2", "C3", "C4", "C5", "C6" };
seriesColl.Add("AW Series 1", categories, new double[] { 1, 2, 2.5, 4, 5, 6 });
seriesColl.Add("AW Series 2", categories, new double[] { 2, 3, 3.5, 6, 6.5, 7 });
//docxファイルに保存するする
document.SaveToFile("AppendLineChart.docx", FileFormat.Docx);//Documentを作成する
Document document = new Document();
//新しいセクションを作成する
Section section = document.AddSection();
//新しい段落を作成してテキストを追加する
section.AddParagraph().AppendText("Pie chart.");
//新しい段落を作成して円グラフを追加する
Paragraph newPara = section.AddParagraph();
ShapeObject shape = newPara.AppendChart(ChartType.Pie, 500, 300);
Chart chart = shape.Chart;
//各セクターのカテゴリ名とその頻度値を含むカスタムグラフシリーズを挿入する
ChartSeries series = chart.Series.Add("Test Series",
new[] { "Word", "PDF", "Excel" },
new[] { 2.7, 3.2, 0.8 });
//docxファイルに保存する
document.SaveToFile("AppendPieChart.docx", FileFormat.Docx);//Documentを作成する
Document document = new Document();
//新しいセクションを作成する
Section section = document.AddSection();
//新しい段落を作成してテキストを追加する
section.AddParagraph().AppendText("Scatter chart.");
//新しい段落を作成して散布図を追加する
Paragraph newPara = section.AddParagraph();
ShapeObject shape = newPara.AppendChart(ChartType.Scatter, 450, 300);
Chart chart = shape.Chart;
//グラフのシリーズデータを消去して、新しいグラフで始める
chart.Series.Clear();
//5 点の X/Y 座標を持つシリーズを挿入する
chart.Series.Add("Scatter chart",
new[] { 1.0, 2.0, 3.0, 4.0, 5.0 },
new[] { 1.0, 20.0, 40.0, 80.0, 160.0 });
//docxファイルに保存する
document.SaveToFile("AppendScatterChart.docx", FileFormat.Docx);//Documentを作成する
Document document = new Document();
//新しいセクションを作成する
Section section = document.AddSection();
//新しい段落を作成してテキストを追加する
section.AddParagraph().AppendText("Surface3D chart.");
//新しい段落を作成してsurface 3Dグラフを追加する
Paragraph newPara = section.AddParagraph();
ShapeObject shape = newPara.AppendChart(ChartType.Surface3D, 500, 300);
//グラフのシリーズデータを消去して、新しいグラフで始める
Chart chart = shape.Chart;
chart.Series.Clear();
chart.Title.Text = "My chart";
//3シリーズを追加する
chart.Series.Add("Series 1",
new string[] { "Word", "PDF", "Excel", "GoogleDocs", "Office" },
new double[] { 1900000, 850000, 2100000, 600000, 1500000 });
chart.Series.Add("Series 2",
new string[] { "Word", "PDF", "Excel", "GoogleDocs", "Office" },
new double[] { 900000, 50000, 1100000, 400000, 2500000 });
chart.Series.Add("Series 3",
new string[] { "Word", "PDF", "Excel", "GoogleDocs", "Office" },
new double[] { 500000, 820000, 1500000, 400000, 100000 });
//docxファイルに保存する
document.SaveToFile("AppendSurface3DChart.docx", FileFormat.Docx);//Documentを作成する
Document document = new Document();
//新しいセクションを作成する
Section section = document.AddSection();
//新しい段落を作成してテキストを追加する
section.AddParagraph().AppendText("Bar chart.");
//新しい段落を作成して棒グラフを追加する
Paragraph newPara = section.AddParagraph();
ShapeObject chartShape = newPara.AppendChart(ChartType.Bar, 400, 300);
Chart chart = chartShape.Chart;
//「Title」プロパティを使用して、グラフ領域の上部中央に表示される棒グラフの見出しを提供する
ChartTitle title = chart.Title;
title.Text = "My Chart";
//「Show」プロパティを「true」に設定して見出しを表示する.
title.Show = true;
//「Overlay」プロパティを「true」に設定します。他のグラフ要素がタイトルと重なるようにすることで、より多くのスペースを提供する
title.Overlay = true;
//docxファイルに保存する
document.SaveToFile("AppendBarChart.docx", FileFormat.Docx); |
| New feature | - | SVGドキュメントを追加する機能がサポートされています。
Document document = new Document(); Section section = document.AddSection(); string svgFile = "sample.svg"; Paragraph para = section.AddParagraph(); DocPicture svgPicture = para.AppendPicture(svgFile); svgPicture.Width = 200; svgPicture.Height = 200; String DocxResult = "Result-AddSvg.docx"; document.SaveToFile(DocxResult, FileFormat.Docx2016); |
| New feature | - | 1ページに複数ページを印刷する機能がサポートされています。
doc.LoadFromFile(inputFile, FileFormat.Docx); System.Windows.Forms.PrintDialog printDialog = new System.Windows.Forms.PrintDialog(); printDialog.PrinterSettings.PrintToFile = true; printDialog.PrinterSettings.PrintFileName = "sample-new-4.xps"; doc.PrintDialog = printDialog; doc.PrintMultipageToOneSheet(PagesPreSheet.FourPages, true); |
| New feature | - | ページの内容や内容の座標を取得するなど、ページを操作する機能がサポートされています。
Document doc = new Document();
doc.LoadFromFile(inputFile, FileFormat.Docx);
FixedLayoutDocument layoutDoc = new FixedLayoutDocument(doc);
//最初のページの行にアクセスし、コンソールに印刷する
FixedLayoutLine line = layoutDoc.Pages[0].Columns[0].Lines[0];
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.AppendLine("Line: " + line.Text);
//レンダリングされた行には、元の段落を文書オブジェクトモデルから取得することができる
Paragraph para = line.Paragraph;
stringBuilder.AppendLine("Paragraph text: " + para.Text);
//ヘッダーとフッターを含むプレーンテキスト形式で、最初のページに表示されたすべてのテキストを取得する
string pageText = layoutDoc.Pages[0].Text;
stringBuilder.AppendLine(pageText);
//文書内の各ページをループし、各ページに表示される行数を印刷する
foreach (FixedLayoutPage page in layoutDoc.Pages)
{
LayoutCollection lines = page.GetChildEntities(LayoutElementType.Line, true);
stringBuilder.AppendLine("Page " + page.PageIndex + " has " + lines.Count + " lines.");
}
//このメソッドは、任意のノードのレイアウトエンティティの逆引き参照を提供する
//「ヘッダーとフッターのrunsとnodesを除く」
stringBuilder.AppendLine("The lines of the first paragraph:");
foreach (FixedLayoutLine paragraphLine in layoutDoc.GetLayoutEntitiesOfNode(
((Section)doc.FirstChild).Body.Paragraphs[0]))
{
stringBuilder.AppendLine(paragraphLine.Text.Trim());
stringBuilder.AppendLine(paragraphLine.Rectangle.ToString());
}
File.WriteAllText("page.txt", stringBuilder.ToString()); |
ここで Spire.Doc 11.5.6をダウンロードする






