Hi everybody,
anyone knows where I may find code samples for "OpenXML Explained book" found on this page
http://openxmldeveloper.org/blog/b/openxmldeveloper/archive/2007/08/13/1970.aspx ?
the code link is broken.
Thanks and regards
paolo
book ""
Hi everybody,
anyone knows where I may find code samples for "OpenXML Explained book" found on this page
http://openxmldeveloper.org/blog/b/openxmldeveloper/archive/2007/08/13/1970.aspx ?
the code link is broken.
Thanks and regards
paolo
book ""
I downloaded a ppt file and its archived in zip format. When I extracted it, I found that, its having many folders and xml files. I am not able to see the ppt file. The zip file contains : -rels, docProps, ppt, folders and [Content_Types].xml file. The contents of the [Content_Types].xml file is given below.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"><Override PartName="/ppt/slideLayouts/slideLayout7.xml" ContentType="application/vnd.openxmlformats-officedocument.presentationml.slideLayout+xml"/><Override
PartName="/ppt/slideLayouts/slideLayout8.xml" ContentType="application/vnd.openxmlformats-officedocument.presentationml.slideLayout+xml"/><Default Extension="png" ContentType="image/png"/><Override PartName="/ppt/slideMasters/slideMaster1.xml"
ContentType="application/vnd.openxmlformats-officedocument.presentationml.slideMaster+xml"/><Override PartName="/ppt/presProps.xml" ContentType="application/vnd.openxmlformats-officedocument.presentationml.presProps+xml"/><Override PartName="/ppt/slideLayouts/slideLayout4.xml"
ContentType="application/vnd.openxmlformats-officedocument.presentationml.slideLayout+xml"/><Override PartName="/ppt/slideLayouts/slideLayout5.xml" ContentType="application/vnd.openxmlformats-officedocument.presentationml.slideLayout+xml"/><Override
PartName="/ppt/slideLayouts/slideLayout6.xml" ContentType="application/vnd.openxmlformats-officedocument.presentationml.slideLayout+xml"/><Override PartName="/ppt/slides/slide1.xml" ContentType="application/vnd.openxmlformats-officedocument.presentationml.slide+xml"/><Override
PartName="/ppt/slides/slide2.xml" ContentType="application/vnd.openxmlformats-officedocument.presentationml.slide+xml"/><Override PartName="/ppt/theme/theme1.xml" ContentType="application/vnd.openxmlformats-officedocument.theme+xml"/><Override
PartName="/ppt/slideLayouts/slideLayout2.xml" ContentType="application/vnd.openxmlformats-officedocument.presentationml.slideLayout+xml"/><Override PartName="/ppt/slideLayouts/slideLayout3.xml" ContentType="application/vnd.openxmlformats-officedocument.presentationml.slideLayout+xml"/><Default
Extension="jpeg" ContentType="image/jpeg"/><Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/><Default Extension="xml" ContentType="application/xml"/><Override PartName="/ppt/presentation.xml"
ContentType="application/vnd.openxmlformats-officedocument.presentationml.presentation.main+xml"/><Override PartName="/ppt/slideLayouts/slideLayout1.xml" ContentType="application/vnd.openxmlformats-officedocument.presentationml.slideLayout+xml"/><Override
PartName="/docProps/app.xml" ContentType="application/vnd.openxmlformats-officedocument.extended-properties+xml"/><Override PartName="/ppt/tableStyles.xml" ContentType="application/vnd.openxmlformats-officedocument.presentationml.tableStyles+xml"/><Override
PartName="/ppt/slideLayouts/slideLayout11.xml" ContentType="application/vnd.openxmlformats-officedocument.presentationml.slideLayout+xml"/><Override PartName="/ppt/slideLayouts/slideLayout10.xml" ContentType="application/vnd.openxmlformats-officedocument.presentationml.slideLayout+xml"/><Override
PartName="/ppt/viewProps.xml" ContentType="application/vnd.openxmlformats-officedocument.presentationml.viewProps+xml"/><Override PartName="/ppt/slideLayouts/slideLayout9.xml" ContentType="application/vnd.openxmlformats-officedocument.presentationml.slideLayout+xml"/><Override
PartName="/docProps/core.xml" ContentType="application/vnd.openxmlformats-package.core-properties+xml"/></Types>
How to open this ppt file. Looking forward to MSDN Community help to open the same.
I'm very close on this.
I'm trying to create a function that will locate and update an embeded chart within a Word document. Ultimately, the document will have sevral charts.
So far, my function can iterate through the document and find a chart (currently there is only one) and plug in some dummy info. It works, however when the document is opened, I get a pop-up complaining that the document is corrupt. I OK past that and a second pop-up asks me if I'd like to recover the document. I OK that and the document then opens and the chart is updated, all as if nothing were wrong.
So it winds up OK, but my users are not going to be happy with the "corrupt file" messages. When they're not happy, no one is happy.
Also, I'm looking for a methodology to find and update a specific chart. Currently I iterate through the document, and if I had to I could live with that but I'd like to implement something a little less fragile.
I was looking at perhaps using the "Title" property on the chart and attempting to have the SDK search for that. I'm a relative newbie to this SDK and can't seem to locate an example of that (or *ANYTHING* for that matter that attempts to find a specific chart in a document).
Here is my code so far. It's just a prototype, so it is maufacturing data for the cells and allthough it is iterating through the document, there is no method yet to target a specific chart:
private void updateChart( WordprocessingDocument doc ) { string rid = null; Stream stream = null; foreach ( Paragraph p in doc.MainDocumentPart.Document.Body.Elements<Paragraph>( ) ) { foreach ( Drawing d in p.Descendants<Drawing>( ) ) { foreach ( ChartReference cr in d.Descendants<ChartReference>( ) ) { rid = cr.Id.Value; ChartPart cp = ( ChartPart )doc.MainDocumentPart.Parts.Where( pt => pt.RelationshipId == rid ).FirstOrDefault( ).OpenXmlPart; foreach ( ExternalData ed in cp.ChartSpace.Elements< ExternalData >( ) ) { string externalDataRID = ed.Id.Value; EmbeddedPackagePart epp = ( EmbeddedPackagePart )cp.Parts.Where( pt => pt.RelationshipId == ed.Id ).FirstOrDefault( ).OpenXmlPart; using ( Stream str = epp.GetStream( ) ) { using ( MemoryStream ms = new MemoryStream( ) ) { CopyStream( str, ms ); using ( SpreadsheetDocument spreadsheetDoc = SpreadsheetDocument.Open( ms, true ) ) { ss.Sheet ws = ( ss.Sheet )spreadsheetDoc.WorkbookPart.Workbook.Sheets.FirstOrDefault( ); string sheetId = ws.Id; WorksheetPart wsp = ( WorksheetPart )spreadsheetDoc.WorkbookPart.Parts.Where( pt => pt.RelationshipId == sheetId ).FirstOrDefault( ).OpenXmlPart; ss.SheetData sd = wsp.Worksheet.Elements<ss.SheetData>( ).FirstOrDefault( ); int ctr = 0; foreach ( ss.Row row in sd.Elements< ss.Row >( ) ) { if ( ctr > 0 && ctr <= 6 ) { ss.CellValue cv0 = row.Elements<ss.Cell>( ).ElementAt( 0 ).Elements<ss.CellValue>( ).FirstOrDefault( ); cv0.Text = _monthsInRange[ ctr - 1 ].startDate.ToString( "MMM-yyyy" ); ss.CellValue cv1 = row.Elements<ss.Cell>( ).ElementAt( 1 ).Elements<ss.CellValue>( ).FirstOrDefault( ); cv1.Text = ( ctr * 10 ).ToString( ); ss.CellValue cv2 = row.Elements<ss.Cell>( ).ElementAt( 2 ).Elements<ss.CellValue>( ).FirstOrDefault( ); cv2.Text = ( ctr * 10 ).ToString( ); ss.CellValue cv3 = row.Elements<ss.Cell>( ).ElementAt( 3 ).Elements<ss.CellValue>( ).FirstOrDefault( ); cv3.Text = ( ctr * 10 ).ToString( ); ss.CellValue cv4 = row.Elements<ss.Cell>( ).ElementAt( 4 ).Elements<ss.CellValue>( ).FirstOrDefault( ); cv4.Text = ( ctr * 10 ).ToString( ); ss.CellValue cv5 = row.Elements<ss.Cell>( ).ElementAt( 5 ).Elements<ss.CellValue>( ).FirstOrDefault( ); cv5.Text = ( ctr * 10 ).ToString( ); }++ctr; } } using ( Stream s = epp.GetStream( ) ) { ms.WriteTo( s ); } } } Chart chart = cp.ChartSpace.Elements<Chart>( ).First( ); Bar3DChart bc = chart.Descendants<DocumentFormat.OpenXml.Drawing.Charts.Bar3DChart>( ).FirstOrDefault( ); if ( bc != null ) { foreach( BarChartSeries bcs in bc.Elements<BarChartSeries>( ) ) { CategoryAxisData cad = bcs.Descendants<CategoryAxisData>( ).FirstOrDefault( ); StringReference sr = cad.Descendants<StringReference>( ).FirstOrDefault( ); StringCache sc = sr.Descendants<StringCache>( ).First( ); int ctr = 0; foreach ( StringPoint sp in sc.Descendants<StringPoint>( ) ) { NumericValue nv = sp.Descendants<NumericValue>( ).First( ); nv.Text = _monthsInRange[ ctr ].startDate.ToString( "MMM-yyyy" );++ctr; } foreach ( Values values in bcs.Descendants<Values>( ) ) { NumberingCache nc = values.Descendants<NumberingCache>( ).First( ); NumericValue nv1 = nc.Elements<NumericPoint>( ).ElementAt( 0 ).Elements<NumericValue>( ).FirstOrDefault( ); nv1.Text = "10"; NumericValue nv2 = nc.Elements<NumericPoint>( ).ElementAt( 1 ).Elements<NumericValue>( ).FirstOrDefault( ); nv2.Text = "20"; NumericValue nv3 = nc.Elements<NumericPoint>( ).ElementAt( 2 ).Elements<NumericValue>( ).FirstOrDefault( ); nv3.Text = "30"; NumericValue nv4 = nc.Elements<NumericPoint>( ).ElementAt( 3 ).Elements<NumericValue>( ).FirstOrDefault( ); nv4.Text = "40"; NumericValue nv5 = nc.Elements<NumericPoint>( ).ElementAt( 4 ).Elements<NumericValue>( ).FirstOrDefault( ); nv5.Text = "50"; NumericValue nv6 = nc.Elements<NumericPoint>( ).ElementAt( 5 ).Elements<NumericValue>( ).FirstOrDefault( ); nv6.Text = "60"; } } } } } } } }
The embedded chart is based off a 5 column (well actually 6 - the first column is row headers) x 6 row spreadsheet.
Any help would be much appreciated.
JP
JP
Hi ,
I am new to Open xml , and i have a scenario that i couln't find out solution.
I have number of tables in the Excel workbook. Now i could store all the tables name and its content in a dataset , with this information in the dataset, how can i draw the table in powerpoint presentation using Openxml. This process should be a dynamic one, because the rows and columns of the table will vary for every table, so we cannot set a default rows and colums for the table .
Sample Table:
please help me in finding the solution. Expecting your replies !!
Thanks in Advance ....
banu
banupriya
I have a problem extracting embedded xlsx files in an xlsx file.
I can get the embeddedpackageparts by worksheetpart.embeddedpackageparts. Howover, I dont have the row and col information of the embeddedpackageparts.
So how do I extract the embeddedpackagepart if I know the sheet name and row and column numbers of the cell where the embeddedpackagepart resides in?
I just want to know the position of each embeddedpackagepart in the sheet because I have multiple embedded xlsx files in the sheet. If I dont know the row and col number, I cant differentiate which embedded file is which because their names are just worksheet1, worksheet2, ....
Hi,
Currently I am using Open XML to convert an XML file to an Excel.
The code workes fine for small xml files but throws out of Memory Exception when tested with large file like above 10MB.
Can anyone provide me some pointers how this can be resolved.
Thanks,
MishraA
Thanks, MishraA
Hi All,
I want to convert Excel file into PDF without using Office PIA but with Sharepoint. Is there any support for this in Sharepoint 2010 or 2013? If not then can you tell me how to do that?
Thanks.
Hi ,
i am new to open xml. i have some requirement for my project.
i need to insert text or paragraphs in the powerpoint slide dynamically that is coming from excel sheet .
Excel is the source document which contains texts and paragraphs.
For example : sheet 1 contains the following information. i need to retrieve these informations and write it into the powerpoint presentation. if the text limit reaches the end of the slide it should automatically create a new slide.
i created an empty presentation using openxml with PresentationParts,SlidePart,SlideLayoutPart,SlideMasterPart,Theme.
My Code:
public void generate_click(object sender, EventArgs e) { string scode = "C:\\Users\\302480\\Documents\\Visual Studio 2010\\Projects\\ppt\\ppt\\Source\\Excel_Source_ppt\\test.pptx"; CreatePresentation(scode); sExcelPath = Server.MapPath("~/Source/Excel_Source_ppt/") + ConfigurationManager.AppSettings["TEMS_ppt"].ToString(); sConnString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + sExcelPath + ".xlsx;Extended Properties=Excel 12.0"; Get_WorkSheet_Names(); Get_Excel_Data(); foreach (DataTable table in dsSOW.Tables) { foreach (DataRow dr in table.Rows) { no = dr.ItemArray[0].ToString(); desc = dr.ItemArray[1].ToString(); data = no+ " " + desc; } } private void Get_WorkSheet_Names() { string sWorkSheetsColl = String.Empty; { int iIndex = 0; oConn = new OleDbConnection(sConnString); oConn.Open(); dtList = oConn.GetSchema("Tables"); if (dtList != null) { dsSOW = new DataSet(); foreach (DataRow dr in dtList.Rows) { if (dr["TABLE_NAME"].ToString().ToLower() != "_xlnm#_filterdatabase") { dsSOW.Tables.Add(dr["TABLE_NAME"].ToString()); sWorkSheetsColl += dr["TABLE_NAME"].ToString() + ","; iIndex++; } } sWorkSheetsColl = sWorkSheetsColl.TrimEnd(','); sWorkSheets = sWorkSheetsColl.Split(','); dsSOW.AcceptChanges(); } } } private void Get_Excel_Data() { for (int i = 0; i < sWorkSheets.Length; i++) { oCmd = new OleDbCommand("SELECT * FROM [" + sWorkSheets[i].TrimEnd() + "]", oConn); oDa = new OleDbDataAdapter(); oDa.SelectCommand = oCmd; oDa.Fill(dsSOW.Tables[sWorkSheets[i].ToString()]); } oConn.Close(); dsSOW.AcceptChanges(); }
public static void CreatePresentation(string filepath) { // Create a presentation at a specified file path. The presentation document type is pptx, by default. PresentationDocument presentationDoc = PresentationDocument.Create(filepath, PresentationDocumentType.Presentation); PresentationPart presentationPart = presentationDoc.AddPresentationPart(); presentationPart.Presentation = new Presentation(); CreatePresentationParts(presentationPart); // Close the presentation handle presentationDoc.Close(); } private static void CreatePresentationParts(PresentationPart presentationPart) { SlideMasterIdList slideMasterIdList1 = new SlideMasterIdList(new SlideMasterId() { Id = (UInt32Value)2147483648U, RelationshipId = "rId1" }); SlideIdList slideIdList1 = new SlideIdList(new SlideId() { Id = (UInt32Value)256U, RelationshipId = "rId2" }); SlideSize slideSize1 = new SlideSize() { Cx = 9144000, Cy = 6858000, Type = SlideSizeValues.Screen4x3 }; NotesSize notesSize1 = new NotesSize() { Cx = 6858000, Cy = 9144000 }; DefaultTextStyle defaultTextStyle1 = new DefaultTextStyle(); presentationPart.Presentation.Append(slideMasterIdList1, slideIdList1, slideSize1, notesSize1, defaultTextStyle1); SlidePart slidePart1; SlideLayoutPart slideLayoutPart1; SlideMasterPart slideMasterPart1; ThemePart themePart1; slidePart1 = CreateSlidePart(presentationPart); slideLayoutPart1 = CreateSlideLayoutPart(slidePart1); slideMasterPart1 = CreateSlideMasterPart(slideLayoutPart1); themePart1 = CreateTheme(slideMasterPart1); slideMasterPart1.AddPart(slideLayoutPart1, "rId1"); presentationPart.AddPart(slideMasterPart1, "rId1"); presentationPart.AddPart(themePart1, "rId5"); } private static SlidePart CreateSlidePart(PresentationPart presentationPart) { SlidePart slidePart1 = presentationPart.AddNewPart<SlidePart>("rId2"); ImagePart imagePart = slidePart1.AddNewPart<ImagePart>("image/jpg", "rId2"); string filepath = @"C:\Users\302480\Documents\Visual Studio 2010\Projects\ppt\ppt\Source\Images\DDT.jpg"; FileStream stream = new FileStream(filepath, FileMode.Open); imagePart.FeedData(stream); stream.Close(); slidePart1.Slide = new Slide( new CommonSlideData( new ShapeTree( new P.NonVisualGroupShapeProperties( new P.NonVisualDrawingProperties() { Id = (UInt32Value)1U, Name = "" }, new P.NonVisualGroupShapeDrawingProperties(), new ApplicationNonVisualDrawingProperties()), new GroupShapeProperties(new TransformGroup()), new P.Shape( new P.NonVisualShapeProperties( new P.NonVisualDrawingProperties() { Id = (UInt32Value)2U, Name = "Title 1" }, new P.NonVisualShapeDrawingProperties(new ShapeLocks() { NoGrouping = true }), new ApplicationNonVisualDrawingProperties(new PlaceholderShape())), new P.ShapeProperties(), new P.TextBody( new BodyProperties(), new ListStyle(), new Paragraph(new EndParagraphRunProperties() { Language = "en-US" }))))), new ColorMapOverride(new MasterColorMapping())); P.Picture picture = new P.Picture(); P.BlipFill blipFill = new P.BlipFill(); D.Blip blip = new D.Blip() { Embed = "rId2" }; Stretch stretch = new Stretch(); FillRectangle fillRectangle = new FillRectangle(); stretch.Append(fillRectangle); blipFill.Append(blip); blipFill.Append(stretch); BlipExtensionList blipExtensionList1 = new BlipExtensionList(); BlipExtension blipExtension1 = new BlipExtension() { Uri = "{28A0092B-C50C-407E-A947-70E740481C1C}" }; UseLocalDpi useLocalDpi1 = new UseLocalDpi() { Val = false }; useLocalDpi1.AddNamespaceDeclaration("a14", "http://schemas.microsoft.com/office/drawing/2010/main"); blipExtension1.Append(useLocalDpi1); blipExtensionList1.Append(blipExtension1); blip.Append(blipExtensionList1); picture.Append(blipFill); P.ShapeProperties shapeProperties1 = new P.ShapeProperties(); D.Transform2D transform2D1 = new D.Transform2D(); D.Offset offset1 = new D.Offset() { X = 667544L, Y = 648680L }; D.Extents extents1 = new D.Extents() { Cx = 5743848L, Cy = 4886743L }; transform2D1.Append(offset1); transform2D1.Append(extents1); D.PresetGeometry presetGeometry1 = new D.PresetGeometry() { Preset = D.ShapeTypeValues.Rectangle }; D.AdjustValueList adjustValueList1 = new D.AdjustValueList(); presetGeometry1.Append(adjustValueList1); shapeProperties1.Append(transform2D1); shapeProperties1.Append(presetGeometry1); picture.Append(shapeProperties1); slidePart1.Slide.CommonSlideData.ShapeTree.Append(picture); return slidePart1; } private static SlideLayoutPart CreateSlideLayoutPart(SlidePart slidePart1) { SlideLayoutPart slideLayoutPart1 = slidePart1.AddNewPart<SlideLayoutPart>("rId1"); SlideLayout slideLayout = new SlideLayout( new CommonSlideData(new ShapeTree( new P.NonVisualGroupShapeProperties( new P.NonVisualDrawingProperties() { Id = (UInt32Value)1U, Name = "" }, new P.NonVisualGroupShapeDrawingProperties(), new ApplicationNonVisualDrawingProperties()), new GroupShapeProperties(new TransformGroup()), new P.Shape( new P.NonVisualShapeProperties( new P.NonVisualDrawingProperties() { Id = (UInt32Value)2U, Name = "" }, new P.NonVisualShapeDrawingProperties(new ShapeLocks() { NoGrouping = true }), new ApplicationNonVisualDrawingProperties(new PlaceholderShape())), new P.ShapeProperties(), new P.TextBody( new BodyProperties(), new ListStyle(), new Paragraph(new EndParagraphRunProperties()))))), new ColorMapOverride(new MasterColorMapping())); slideLayoutPart1.SlideLayout = slideLayout; return slideLayoutPart1; } private static SlideMasterPart CreateSlideMasterPart(SlideLayoutPart slideLayoutPart1) { SlideMasterPart slideMasterPart1 = slideLayoutPart1.AddNewPart<SlideMasterPart>("rId1"); SlideMaster slideMaster = new SlideMaster( new CommonSlideData(new ShapeTree( new P.NonVisualGroupShapeProperties( new P.NonVisualDrawingProperties() { Id = (UInt32Value)1U, Name = "" }, new P.NonVisualGroupShapeDrawingProperties(), new ApplicationNonVisualDrawingProperties()), new GroupShapeProperties(new TransformGroup()), new P.Shape( new P.NonVisualShapeProperties( new P.NonVisualDrawingProperties() { Id = (UInt32Value)2U, Name = "Title Placeholder 1" }, new P.NonVisualShapeDrawingProperties(new ShapeLocks() { NoGrouping = true }), new ApplicationNonVisualDrawingProperties(new PlaceholderShape() { Type = PlaceholderValues.Title })), new P.ShapeProperties(), new P.TextBody( new BodyProperties(), new ListStyle(), new Paragraph())))), new P.ColorMap() { Background1 = D.ColorSchemeIndexValues.Light1, Text1 = D.ColorSchemeIndexValues.Dark1, Background2 = D.ColorSchemeIndexValues.Light2, Text2 = D.ColorSchemeIndexValues.Dark2, Accent1 = D.ColorSchemeIndexValues.Accent1, Accent2 = D.ColorSchemeIndexValues.Accent2, Accent3 = D.ColorSchemeIndexValues.Accent3, Accent4 = D.ColorSchemeIndexValues.Accent4, Accent5 = D.ColorSchemeIndexValues.Accent5, Accent6 = D.ColorSchemeIndexValues.Accent6, Hyperlink = D.ColorSchemeIndexValues.Hyperlink, FollowedHyperlink = D.ColorSchemeIndexValues.FollowedHyperlink }, new SlideLayoutIdList(new SlideLayoutId() { Id = (UInt32Value)2147483649U, RelationshipId = "rId1" }), new TextStyles(new TitleStyle(), new BodyStyle(), new OtherStyle())); slideMasterPart1.SlideMaster = slideMaster; return slideMasterPart1; } private static ThemePart CreateTheme(SlideMasterPart slideMasterPart1) { ThemePart themePart1 = slideMasterPart1.AddNewPart<ThemePart>("rId5"); D.Theme theme1 = new D.Theme() { Name = "Office Theme" }; D.ThemeElements themeElements1 = new D.ThemeElements( new D.ColorScheme( new D.Dark1Color(new D.SystemColor() { Val = D.SystemColorValues.WindowText, LastColor = "000000" }), new D.Light1Color(new D.SystemColor() { Val = D.SystemColorValues.Window, LastColor = "FFFFFF" }), new D.Dark2Color(new D.RgbColorModelHex() { Val = "1F497D" }), new D.Light2Color(new D.RgbColorModelHex() { Val = "EEECE1" }), new D.Accent1Color(new D.RgbColorModelHex() { Val = "4F81BD" }), new D.Accent2Color(new D.RgbColorModelHex() { Val = "C0504D" }), new D.Accent3Color(new D.RgbColorModelHex() { Val = "9BBB59" }), new D.Accent4Color(new D.RgbColorModelHex() { Val = "8064A2" }), new D.Accent5Color(new D.RgbColorModelHex() { Val = "4BACC6" }), new D.Accent6Color(new D.RgbColorModelHex() { Val = "F79646" }), new D.Hyperlink(new D.RgbColorModelHex() { Val = "0000FF" }), new D.FollowedHyperlinkColor(new D.RgbColorModelHex() { Val = "800080" })) { Name = "Office" }, new D.FontScheme( new D.MajorFont( new D.LatinFont() { Typeface = "Calibri" }, new D.EastAsianFont() { Typeface = "" }, new D.ComplexScriptFont() { Typeface = "" }), new D.MinorFont( new D.LatinFont() { Typeface = "Calibri" }, new D.EastAsianFont() { Typeface = "" }, new D.ComplexScriptFont() { Typeface = "" })) { Name = "Office" }, new D.FormatScheme( new D.FillStyleList( new D.SolidFill(new D.SchemeColor() { Val = D.SchemeColorValues.PhColor }), new D.GradientFill( new D.GradientStopList( new D.GradientStop(new D.SchemeColor(new D.Tint() { Val = 50000 }, new D.SaturationModulation() { Val = 300000 }) { Val = D.SchemeColorValues.PhColor }) { Position = 0 }, new D.GradientStop(new D.SchemeColor(new D.Tint() { Val = 37000 }, new D.SaturationModulation() { Val = 300000 }) { Val = D.SchemeColorValues.PhColor }) { Position = 35000 }, new D.GradientStop(new D.SchemeColor(new D.Tint() { Val = 15000 }, new D.SaturationModulation() { Val = 350000 }) { Val = D.SchemeColorValues.PhColor }) { Position = 100000 } ), new D.LinearGradientFill() { Angle = 16200000, Scaled = true }), new D.NoFill(), new D.PatternFill(), new D.GroupFill()), new D.LineStyleList( new D.Outline( new D.SolidFill( new D.SchemeColor( new D.Shade() { Val = 95000 }, new D.SaturationModulation() { Val = 105000 }) { Val = D.SchemeColorValues.PhColor }), new D.PresetDash() { Val = D.PresetLineDashValues.Solid }) { Width = 9525, CapType = D.LineCapValues.Flat, CompoundLineType = D.CompoundLineValues.Single, Alignment = D.PenAlignmentValues.Center }, new D.Outline( new D.SolidFill( new D.SchemeColor( new D.Shade() { Val = 95000 }, new D.SaturationModulation() { Val = 105000 }) { Val = D.SchemeColorValues.PhColor }), new D.PresetDash() { Val = D.PresetLineDashValues.Solid }) { Width = 9525, CapType = D.LineCapValues.Flat, CompoundLineType = D.CompoundLineValues.Single, Alignment = D.PenAlignmentValues.Center }, new D.Outline( new D.SolidFill( new D.SchemeColor( new D.Shade() { Val = 95000 }, new D.SaturationModulation() { Val = 105000 }) { Val = D.SchemeColorValues.PhColor }), new D.PresetDash() { Val = D.PresetLineDashValues.Solid }) { Width = 9525, CapType = D.LineCapValues.Flat, CompoundLineType = D.CompoundLineValues.Single, Alignment = D.PenAlignmentValues.Center }), new D.EffectStyleList( new D.EffectStyle( new D.EffectList( new D.OuterShadow( new D.RgbColorModelHex( new D.Alpha() { Val = 38000 }) { Val = "000000" }) { BlurRadius = 40000L, Distance = 20000L, Direction = 5400000, RotateWithShape = false })), new D.EffectStyle( new D.EffectList( new D.OuterShadow( new D.RgbColorModelHex( new D.Alpha() { Val = 38000 }) { Val = "000000" }) { BlurRadius = 40000L, Distance = 20000L, Direction = 5400000, RotateWithShape = false })), new D.EffectStyle( new D.EffectList( new D.OuterShadow( new D.RgbColorModelHex( new D.Alpha() { Val = 38000 }) { Val = "000000" }) { BlurRadius = 40000L, Distance = 20000L, Direction = 5400000, RotateWithShape = false }))), new D.BackgroundFillStyleList( new D.SolidFill(new D.SchemeColor() { Val = D.SchemeColorValues.PhColor }), new D.GradientFill( new D.GradientStopList( new D.GradientStop( new D.SchemeColor(new D.Tint() { Val = 50000 }, new D.SaturationModulation() { Val = 300000 }) { Val = D.SchemeColorValues.PhColor }) { Position = 0 }, new D.GradientStop( new D.SchemeColor(new D.Tint() { Val = 50000 }, new D.SaturationModulation() { Val = 300000 }) { Val = D.SchemeColorValues.PhColor }) { Position = 0 }, new D.GradientStop( new D.SchemeColor(new D.Tint() { Val = 50000 }, new D.SaturationModulation() { Val = 300000 }) { Val = D.SchemeColorValues.PhColor }) { Position = 0 }), new D.LinearGradientFill() { Angle = 16200000, Scaled = true }), new D.GradientFill( new D.GradientStopList( new D.GradientStop( new D.SchemeColor(new D.Tint() { Val = 50000 }, new D.SaturationModulation() { Val = 300000 }) { Val = D.SchemeColorValues.PhColor }) { Position = 0 }, new D.GradientStop( new D.SchemeColor(new D.Tint() { Val = 50000 }, new D.SaturationModulation() { Val = 300000 }) { Val = D.SchemeColorValues.PhColor }) { Position = 0 }), new D.LinearGradientFill() { Angle = 16200000, Scaled = true }))) { Name = "Office" }); theme1.Append(themeElements1); theme1.Append(new D.ObjectDefaults()); theme1.Append(new D.ExtraColorSchemeList()); themePart1.Theme = theme1; return themePart1; }
banu
banupriya
HI I am using Open XML SDK. I generated a report(docx) file with content controls having xpath. The xml data file from which the xpath needs to evaluated also embedded. The report is generated correctly showing the value evaluated from the xpath.
My Problem when I load the same document using the Open XML API I am seeing blank values instead of the actual contents.
Can you please let me know why it is happening and what do I need to do to see the actual report values?
Thanks and Regards
Kiran M
Kiran Madiraju
Hi There,
I have created a new docx document and want to open it using the OpenXML SDK.
Here is my code:
Package package = Package.Open(document); WordprocessingDocument doc = WordprocessingDocument.Open(package);
When the code is executed I get the following error:
The specified package is invalid. The main part is missing
Can someone help please!
Ek hoor stemme
Can somebody help me on how to convert my xml spreadsheet 2003 to Excel? I have a page which uses openxml template but the problem is after i rename it to xls extension. this error prompts up.
"The file you are trying to open is in different format that specified by the file extension. Verify that the file is not corrupted and is from a trusted source before opening the file. Do you want to open the file now?
Whats great is that excel can actually convert that xml to excel. maybe i can do the same programmatically. Btw im using asp.net c#. Pls help.
Thanks
Hello everyone,
I would like to retrieve the slide size stored in a .thmx theme file produced by PowerPoint. If I try this for a .pptx presentation file all works well. Width and Height get correct values:
string FullPathName = @"C:\Presentation.pptx"; using (PresentationDocument Pres = PresentationDocument.Open(FullPathName, false)) { SlideSize SlSize = Pres.PresentationPart.Presentation.SlideSize; int Width = (int) SlSize.Cy; int Height = (int) SlSize.Cx; }
Unfortunately, it seems I cannot hand a .thmx file to PresentationDocument.Open( ... ). So although a .thmx file also contains the information (in /theme/presentation.xml rather than /ppt/presentation.xml) I cannot access it.
Is there a good way to get to that?
Thanks - any help highly appreciated!
Boris Lehečka (Word, Access, VBA, XML, C#, SQL)
Hi Everyone,
Does any one knows, how to put content controls on the bookmark ranges using open xml sdk?
Thanks,
Shahab Abbasi
I have situation where I need to store meta data for individual cells. Working with OpenXml, i found that there is a provision to add meta index (cell or value) to individual cell.
Refer : Cell Class in Open XML (Do google search)
But there is no detail about the structure of the meta data xml file, also no examples to create cell meta data or value meta data. How can we add the meta data to cell using Open Xml with proper example.
Hi All
I’m using Word 2013 and a SQL Server 2005.
I’ve got a VBA solution in a Word Template which is handling the mail merge action for end users. The end user choses the type of document and the recipients with our database solution and we then call our Word 2013 template where we ask the final questions and then execute the mail merge for the end user. We’ve used that technique since Word 2000 and it worked very well (Generated 50 pages in 6 seconds).
Word 2013 is enormously slow doing the mail merge. It takes 3 times the time as Word 2000. I’ve been told to look into Open XML and that’s where I’m struggling.
We have hundreds of Word templates setup to be used for the mail merge having lots of MERGEFIELDS placed in the document. We even use the Field DATABASE to populate tables.
I plan to keep the VBA code dealing with all the pre-mailmerge tasks interacting with the end user before he hits the button «Do the letters for me». At the point where I execute the VBA code to do the mail merge I’d like to call a C# DLL which I’ve created
with Visual Studio 2010 using Open XML doing the mail merge with Open XML.
At that time I’d have the Word template and the dataset (in a SQL string or all data saved in a RTF file as data source) ready.
Is it possible to write that cute little C# black box DLL using Open XML virtually replacing the Mail Merge VBA command from Word hoping it works faster the good old word mail merge engine? If yes can anybody point me to the right direction for examples, tutorials or help material?
Thanks a lot.
Martin
Hi
Since last few weeks I am struggling with converting infopath forms to word or pdf.
As I have few limitations on site administration I can't use third party solutions. I want to convert forms to word/ pdf because I want to share it externally with non-sharepoint users. So I can't use option to convert infopath to word using workflow. Because it uses a template to store metadata. And non-sharepoint users cannot access this template. Thus unable to open the documents.
One way to do this is convert infopath form to word and then convert word to pdf. But it is time consuming.
Is it possible to create a new word document using client object model or event receiver and write all column values into new document?
Hello,
I have a problem with my Windows 7's configuration.
I create a document with Word 2007 and save it with document XML Word Format (.xml)
in my computer, when i search to open directly (double click) this document, the document is open with my XML editor, and not Microsoft Word
I verify if my XML document contains <?mso-application progid="Word.Document"?>, it's OK,fortunately !
In other computer, in Windows XP SP3, the icon's file is word icon, despite extension file is .XML, not in my Windows 7 computer !
In other computer, an XML file without <?mso-application progid="Word.Document"?> are icon's file XML, it's OK
why, in my computer, the XML preprocessing instruction <?mso-application progid="Word.Document"?> is notinterpreted ?
how it is possible to correct this problem and to obtain icon word when preprocessing instruction <?mso-application progid="Word.Document"?> is available on my XML file and open file with Word. And obtain XML icon and open XML file in XML editor otherwise ? it's a normaly process in Windows XP...
Thank you for your help.
Hi,
In my document I have paragraph which contains 2-3 content controls. I want to copy the whole paragraph including content controls and append at the end of document with a certain number of times using c# code. Without content controls I am able to copy the paragraph. How this should be achieved to copy the paragraph including content controls. I appreciate your help in advance.
Regards,
Imran
I am a chemistry graduate and very new to programming, having learned everything from the Internet. I have a Word document with mail merge fields. The data source is an Excel file. I want to change the datasource Excel file dynamically and save the the merged document in a new file.
public static void mergeDocs() { string fileToOpen = @"D:\CSharpProjects\MailMerge\document.docx"; using (WordprocessingDocument wordDocument = WordprocessingDocument.Open(fileToOpen, true)) { int mailmergecount = wordDocument.MainDocumentPart.DocumentSettingsPart.Settings.Elements<MailMerge>().Count(); Console.WriteLine ("Number of mail merges:{0}", mailmergecount); MailMerge mymerge = wordDocument.MainDocumentPart.DocumentSettingsPart.Settings.Elements<MailMerge>().First(); mymerge.ConnectString.Val = "Provider=Microsoft.ACE.OLEDB.12.0;User ID=Admin;Data Source=D:\\CSharpProjects\\MailMerge\\Data.xlsx;Mode=Read;Extended Properties=\"HDR=YES;IMEX=1;\";Jet OLEDB:System database=\"\";Jet OLEDB:Registry Path=\"\";Jet OLEDB:Engine Type=37;Jet OLEDB:Database Locking Mode=0;Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Global Bulk Transactions=1;Jet OLEDB:New Database Password=\"\";Jet OLEDB:Create System Database=False;Jet OLEDB:Encrypt Database=False;Jet OLEDB:Don\'t Copy Locale on Compact=False;Jet OLEDB:Compact Without Replica Repair=False;Jet OLEDB:SFP=False;Jet OLEDB:Support Complex Data=False"; foreach (var relationship in wordDocument.ExternalRelationships.Where(Rel => Rel.RelationshipType == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/mailMergeSource")) { wordDocument.DeleteExternalRelationship(relationship); } string DataPath = @"D:\CSharpProjects\MailMerge\data1.xlsx"; var dsRelationship = wordDocument.MainDocumentPart.DocumentSettingsPart.AddExternalRelationship("http://schemas.openxmlformats.org/officeDocument/2006/relationships/mailMergeSource", new Uri(string.Format("file:///{0}", DataPath))); mymerge.DataSourceReference.Id = dsRelationship.Id; mymerge.ViewMergedData.Val = true; }
This changes the datasource, but I need to manually finish the merge and save the merged document. How do I automate this process?