We're pleased to announce the release of Spire.Office for JavaScript 11.7.0. This version supports converting Word documents directly to XLSX format and operating on format revision information. Meanwhile, it also supports setting the data label position for charts and adding, modifying, or deleting SmartArt graphics. More details are listed below.
Here is a list of changes made in this release
| Category | ID | Description |
| New Feature | - | Supports converting Word directly to XLSX format.
let doc = new spiredoc.Document();
doc.LoadFromFile(inputFileName);
doc.SaveToFile({fileName: outFileName, fileFormat: spiredoc.FileFormat.XLSX});
spire.copyFileFromFSToLocalStorage(outFileName, outputFile);
doc.Close();
|
| New Feature | - | Supports operating on format revision information.
let doc = new spiredoc.Document();
doc.LoadFromFile(inputFileName);
let revisionInfoCollection = doc.GetRevisionInfos();
for (let i = 0; i < revisionInfoCollection.Count; i++) {
let revisionInfo = revisionInfoCollection.get_Item(i);
if (revisionInfo.RevisionType === spiredoc.RevisionType.FormatChange)
{
revisionInfo.Reject(); // or Accept()
i--;
}
}
doc.SaveToFile({fileName: outFileName, fileFormat: spiredoc.FileFormat.Docx});
spire.copyFileFromFSToLocalStorage(outFileName, outputFile);
doc.Close();
|
| New Feature | - | Supports setting "Automatically adjust right indent when document grid is defined".
let doc = new spiredoc.Document();
doc.LoadFromFile(inputFileName);
let section = doc.Sections.get_Item(0);
let para1 = section.Paragraphs.get_Item(2);
para1.Format.AdjustRightIndent = true;
section.AddParagraph();
let para3 = section.Paragraphs.get_Item(7);
para3.AppendText("News Line Sample");
para3.Format.AdjustRightIndent = true;
doc.SaveToFile({fileName: outFileName, fileFormat: spiredoc.FileFormat.Docx});
spire.copyFileFromFSToLocalStorage(outFileName, outputFile);
doc.Close();
|
| New Feature | - | Paragraph class adds the AppendSmartArt method, supporting appending SmartArt graphics in paragraphs.
let document = new spiredoc.Document();
let section = document.AddSection();
let paragraph = section.AddParagraph();
paragraph.Format.HorizontalAlignment = spiredoc.HorizontalAlignment.Center;
let textRange = paragraph.AppendText("RepeatingBendingProcess");
textRange.CharacterFormat.FontSize = 28;
textRange.CharacterFormat.FontName = "Times New Roman";
paragraph = section.AddParagraph();
paragraph = section.AddParagraph();
paragraph.Format.HorizontalAlignment = spiredoc.HorizontalAlignment.Center;
let shape = paragraph.AppendSmartArt(spiredoc.SmartArtType.RepeatingBendingProcess, 432, 252);
let repeatingBendingSmartArt = shape.SmartArt;
let process1 = repeatingBendingSmartArt.Nodes.get_Item(0);
process1.Text = "1";
if (process1.Paragraphs.get_Item(0).ChildObjects.get_Item(0) instanceof spiredoc.TextRange) {
process1.Paragraphs.get_Item(0).ChildObjects.get_Item(0).CharacterFormat.FontName = "Calibri";
process1.Paragraphs.get_Item(0).ChildObjects.get_Item(0).CharacterFormat.FontSize = 20;
process1.Paragraphs.get_Item(0).ChildObjects.get_Item(0).CharacterFormat.TextColor = spiredoc.Color.FromArgb(220, 20, 60);
}
repeatingBendingSmartArt.UpdateSmartArt();
document.SaveToFile({fileName: outFileName, fileFormat: spiredoc.FileFormat.Docx});
spire.copyFileFromFSToLocalStorage(outFileName, outputFile);
document.Close();
|
| New Feature | - | Supports hiding table rows.
let doc = new spiredoc.Document();
doc.LoadFromFile(inputFileName);
let table = doc.FirstSection.Body.Tables.get_Item(0);
let firstRow = table.FirstRow;
firstRow.Hidden = true;
// Verify CharacterFormat.Hidden of all elements in the row
for (let c = 0; c < row.Cells.Count; c++) {
let cell = row.Cells.get_Item(c);
for (let p = 0; p < cell.Paragraphs.Count; p++) {
let para = cell.Paragraphs.get_Item(p);
for (let r = 0; r < para.ChildObjects.Count; r++) {
let run = para.ChildObjects.get_Item(r);
if (run instanceof spiredoc.TextRange) { ... }
}
}
}
doc.SaveToFile({fileName: outFileName, fileFormat: spiredoc.FileFormat.Docx});
spire.copyFileFromFSToLocalStorage(outFileName, outputFile);
doc.Close();
|
| New Feature | - | Supports drawing underlines on trailing spaces.
let doc = new spiredoc.Document();
doc.CompatibilityOptions.UlTrailSpace = true; // or false
let sec = doc.AddSection();
let para = sec.AddParagraph();
let blanks = "(6) ";
let tr = para.AppendText(blanks);
tr.CharacterFormat.UnderlineStyle = spiredoc.UnderlineStyle.Single;
doc.SaveToFile({fileName: outFileName, fileFormat: spiredoc.FileFormat.Docx2013});
spire.copyFileFromFSToLocalStorage(outFileName, outputFile);
|
| New Feature | - | Supports reading chart data (XValues / YValues).
let doc = new spiredoc.Document();
doc.LoadFromFile(inputFileName);
for (let s = 0; s < doc.Sections.Count; s++) {
let sec = doc.Sections.get_Item(s);
for (let p = 0; p < sec.Paragraphs.Count; p++) {
let paragraph = sec.Paragraphs.get_Item(p);
for (let i = 0; i < paragraph.ChildObjects.Count; i++) {
let obj = paragraph.ChildObjects.get_Item(i);
if (obj instanceof spiredoc.ShapeObject) {
let shape = obj;
let chart = shape.Chart;
// Read X-axis data
for (let x = 0; x < chart.XValues.Count; x++) {
let xVal = chart.XValues.get_Item(x);
}
// Read Y-axis data
let series = chart.Series.get_Item(0);
for (let y = 0; y < series.YValues.Count; y++) {
let yVal = series.YValues.get_Item(y);
}
}
}
}
|
| New Feature | - | Supports obtaining document revision information.
let doc = new spiredoc.Document();
doc.LoadFromFile(inputFileName);
let revisionInfoCollection = doc.GetRevisionInfos();
for (let i = 0; i < revisionInfoCollection.Count; i++) {
let revisionInfo = revisionInfoCollection.get_Item(i);
// Get revision information
let author = revisionInfo.Author;
let revisionType = revisionInfo.RevisionType;
let dateTime = revisionInfo.DateTime;
let ownerObjType = revisionInfo.OwnerObject.DocumentObjectType;
// Determine the target object type
if (revisionInfo.OwnerObject instanceof spiredoc.TextRange) {
let range = revisionInfo.OwnerObject;
}
}
doc.Dispose();
|
| New Feature | - | Supports document compatibility option settings.
let doc = new spiredoc.Document();
// Set individual compatibility options
doc.CompatibilityOptions.UlTrailSpace = false;
doc.CompatibilityOptions.AdjustLineHeightInTable = true;
doc.CompatibilityOptions.SpaceForUL = true;
doc.CompatibilityOptions.ApplyBreakingRules = true;
doc.CompatibilityOptions.DoNotExpandShiftReturn = false;
doc.CompatibilityOptions.OverrideTableStyleFontSizeAndJustification = false;
doc.CompatibilityOptions.DoNotAutofitConstrainedTables = true;
// Optimize for a specific Word version
doc.CompatibilityOptions.OptimizeForWordVersion(spiredoc.WordVersion.Word2016);
doc.SaveToFile({fileName: outFileName, fileFormat: spiredoc.FileFormat.Docx2016});
spire.copyFileFromFSToLocalStorage(outFileName, outputFile);
doc.Close();
|
| New Feature | - | Supports setting "Kerning for fonts".
let doc = new spiredoc.Document();
let sec = doc.AddSection();
for (let item of testData) {
let pa = sec.AddParagraph();
let textRange = pa.AppendText(item.text);
textRange.CharacterFormat.Kerning = item.kerning;
}
doc.SaveToFile({fileName: outFileName, fileFormat: spiredoc.FileFormat.Docx});
spire.copyFileFromFSToLocalStorage(outFileName, outputFile);
doc.Close();
|
| New Feature | - | Supports setting text direction (Horizontal in Vertical).
let doc = new spiredoc.Document();
let section = doc.AddSection();
section.TextDirection = spiredoc.TextDirection.RightToLeft;
let paragraph = section.AddParagraph();
let range = paragraph.AppendText("text");
let farEastLayout2 = paragraph.AppendText("34");
let style = new spiredoc.FarEastLayout();
style.Vertical = true;
farEastLayout2.CharacterFormat.FarEastLayout = style;
doc.SaveToFile({fileName: outFileName, fileFormat: spiredoc.FileFormat.Doc});
spire.copyFileFromFSToLocalStorage(outFileName, outputFile);
doc.Close();
|
| New Feature | - | Supports extracting SmartArt-related information.
let document = new spiredoc.Document();
document.LoadFromFile(inputFileName);
for (let s = 0; s < document.Sections.Count; s++) {
let section = document.Sections.get_Item(s);
for (let p = 0; p < section.Paragraphs.Count; p++) {
let paragraph = section.Paragraphs.get_Item(p);
for (let c = 0; c < paragraph.ChildObjects.Count; c++) {
let childObj = paragraph.ChildObjects.get_Item(c);
if (childObj instanceof spiredoc.Shape && childObj.HasSmartArt) {
let smartArt = childObj.SmartArt;
// Get SmartArt type
let type = smartArt.SmartArtType;
// Get background fill
let bgFillType = smartArt.BackgroundFill.FillType;
// Traverse nodes
for (let n = 0; n < smartArt.Nodes.Count; n++) {
let node = smartArt.Nodes.get_Item(n);
// Node text, font, shape properties
node.Text;
node.ShapeProperties.get(0).Fill.FillType;
node.ShapeProperties.get(0).Fill.Color;
node.ShapeProperties.get(0).LineFormat.Fill.FillType;
}
}
}
}
}
document.Dispose();
|
| New Feature | - | Supports switching the revision view to compare style changes before and after.
let doc = new spiredoc.Document();
doc.LoadFromFile(inputFileName);
let revisionInfoCollection = doc.GetRevisionInfos();
for (let i = 0; i < revisionInfoCollection.Count; i++) {
let revisionInfo = revisionInfoCollection.get_Item(i);
if (revisionInfo.RevisionType === spiredoc.RevisionType.FormatChange) {
if (revisionInfo.OwnerObject instanceof spiredoc.TextRange) {
let range = revisionInfo.OwnerObject;
doc.RevisionsView = spiredoc.RevisionsView.Original;
// Read Original style
let bold = range.CharacterFormat.Bold;
doc.RevisionsView = spiredoc.RevisionsView.Final;
// Read Final style
let color = range.CharacterFormat.TextColor;
}
}
}
doc.Close();
|
| New Feature | - | Supports chart datalabel position settings.
let doc = new spiredoc.Document();
for (let pos of positions) {
let section = doc.AddSection();
let newPara = section.AddParagraph();
let shape = newPara.AppendChart(spiredoc.ChartType.Pie, 500, 300);
let chart = shape.Chart;
chart.Series.get_Item(0).HasDataLabels = true;
chart.Series.get_Item(0).DataLabels.ShowCategoryName = true;
chart.Series.get_Item(0).DataLabels.ShowValue = true;
chart.Series.get_Item(0).DataLabels.Position = pos;
}
doc.SaveToFile({fileName: outFileName, fileFormat: spiredoc.FileFormat.Docx});
spire.copyFileFromFSToLocalStorage(outFileName, outputFile);
doc.Dispose();
|
| New Feature | - | Supports modifying SmartArt graphics.
let document = new spiredoc.Document();
document.LoadFromFile(inputFileName);
let paragraph = document.LastParagraph;
let shape1 = paragraph.ChildObjects.get_Item(0);
let smartArt = shape1.SmartArt;
// Modify background fill
smartArt.BackgroundFill.FillType = spiredoc.FillType.Solid;
smartArt.BackgroundFill.Color = spiredoc.Color.FromArgb(255, 242, 169, 132);
// Modify node text
let node = smartArt.Nodes.get_Item(0);
node.Text = "Goals";
// Modify node fill
let shape = node.ShapeProperties.get(0);
shape.Fill.FillType = spiredoc.FillType.Solid;
shape.Fill.Color = spiredoc.Color.FromArgb(255, 160, 43, 147);
shape.LineFormat.Fill.FillType = spiredoc.FillType.Solid;
shape.LineFormat.Fill.Color = spiredoc.Color.FromArgb(255, 160, 43, 147);
// Add new node
let newNode = smartArt.Nodes.Add();
newNode.Text = "Map";
smartArt.UpdateSmartArt();
document.SaveToFile({fileName: outFileName, fileFormat: spiredoc.FileFormat.Docx});
spire.copyFileFromFSToLocalStorage(outFileName, fullOutputPath);
document.Close();
|
| New Feature | - | Supports deleting SmartArt graphics.
let document = new spiredoc.Document();
document.LoadFromFile(inputFileName);
for (let j = 0; j < document.Sections.get_Item(0).Paragraphs.Count; j++) {
let paragraph = document.Sections.get_Item(0).Paragraphs.get_Item(j);
for (let i = 0; i < paragraph.ChildObjects.Count; i++) {
let childObj = paragraph.ChildObjects.get_Item(i);
try {
let smartArt = childObj.SmartArt;
if (smartArt != null) {
paragraph.Items.RemoveAt(i);
i--;
}
} catch (e) { }
}
}
document.SaveToFile({fileName: outFileName, fileFormat: spiredoc.FileFormat.Docx});
spire.copyFileFromFSToLocalStorage(outFileName, fullOutputPath);
document.Close();
|
Click the link to download Spire.Office for JavaScript 11.7.0: