hi
Am using OpenXML and the DocumentBuilder to open report documents and get the 1st and last items and put them into a new blank Word.docx
The problem is how to resize them? Here is the xml showing the Table,
<w:document xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:c="http://schemas.openxmlformats.org/drawingml/2006/chart" xmlns:wpc="http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:wp14="http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:w14="http://schemas.microsoft.com/office/word/2010/wordml" xmlns:wpg="http://schemas.microsoft.com/office/word/2010/wordprocessingGroup" xmlns:wpi="http://schemas.microsoft.com/office/word/2010/wordprocessingInk" xmlns:wne="http://schemas.microsoft.com/office/word/2006/wordml" xmlns:wps="http://schemas.microsoft.com/office/word/2010/wordprocessingShape" mc:Ignorable="w14 wp14"><w:body><w:p w:rsidR="00B53D27" w:rsidRDefault="009E519C"><w:r><w:t xml:space="preserve">This paragraph shall constitute the first </w:t></w:r><w:proofErr w:type="spellStart" /><w:r><w:t>breadswidth</w:t></w:r><w:proofErr w:type="spellEnd" /><w:r><w:t>.</w:t></w:r></w:p><w:tbl><w:tblPr><w:tblStyle w:val="TableGrid" /><w:tblW w:w="10800" w:type="dxa" />
The table width is also found in the reflected code:
Table table1 = new Table();
TableProperties tableProperties1 = new TableProperties();
TableStyle tableStyle1 = new TableStyle(){ Val = "TableGrid" };
TableWidth tableWidth1 = new TableWidth(){ Width = "10800", Type = TableWidthUnitValues.Dxa };
I want to modify the size of the table here, and then resize the chart so they are the same width and will fit 2-wide on the page.
Here is the general code used to parse one of the report.docx files, there will be 100 or so. The goal is to squish the table/chart from each report.docx so they will fit 2 wide on a new page;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Validation;
using OpenXmlPowerTools;
namespace DocumentBuilderExample
{
class DocumentBuilderExample
{
static void Main(string[] args)
{
var n = DateTime.Now;
var tempDi = new DirectoryInfo(string.Format("ExampleOutput-{0:00}-{1:00}-{2:00}-{3:00}{4:00}{5:00}", n.Year - 2000, n.Month, n.Day, n.Hour, n.Minute, n.Second));
tempDi.Create();
string source1 = "../../Source1.docx";
string source2 = "../../Source1.docx";
string source3 = "../../templage.docx";
List<Source> sources = null;
// Create new document from 10 paragraphs starting at paragraph 5 of Source1.docx
sources = new List<Source>()
{
new Source(new WmlDocument(source3), 0, 1, true),
new Source(new WmlDocument(source1), 0, 2, false),
new Source(new WmlDocument(source2), 19, 1, false)
};
DocumentBuilder.BuildDocument(sources, Path.Combine(tempDi.FullName, "Out1.docx"));
}
}
}
The above code will take my report doc and get the 1st and last item and put that into a new docx file. but the size is untouched from the original.
Using the XElement or by any method known, how could the object(s) be accessed so the size could be modified?