Quantcast
Channel: Open XML Format SDK forum
Viewing all 1288 articles
Browse latest View live

How PowerPoint uses "lang" attribute when it classifies characters?

$
0
0

I tried to find out how PowerPoint shows birectional text from the "Office Open XML File Format Implementation" forum. Unfortunately, because Office Open XML File Format does not specify how text stored in DrawingML format should exactly be shown, that forum could not provide the answer. The specific discussion thread resides in:

http://social.msdn.microsoft.com/Forums/en-US/os_openXML-ecma/thread/2d24887e-37aa-4a32-8422-8ebd18ac01c4

The text run properties within DrawingML may contain a "lang" attribute. PowerPoint uses the "lang" attribute somehow for the classification of characters. Because the effect of the "lang" attribute into the classification of characters is not specified in the DrawingML format, the interoperability of different products using Office Open XML File Format can not be achieved. Files created with PowerPoint can not be read correctly by other programs and files created with other programs can not be read correctly by PowerPoint.

Could someone explain to me how PowerPoint uses the "lang" attribute when it performs the classification of characters?

  Tero


MS EXCEL ISSUE IN MACINTOSH MACHINE

$
0
0

We are using OpenXML library to generate Excel reports, and all these reports are working fine on Win 7 and Office 2010.

 

However some of the users are using Mac machine (Mountain Lion OS) and Office 2011 for Mac, when these users open the excel file for the first time it works fine, but when they save this file and open again it throws a message telling there are some unreadable contents and gives an option to repair the file, once the file is repaired it loses all the formatting done in excel.

 


Read Excel 2007 file with Open XML - Identify blank cell

$
0
0

Hi

I am working on a .NET 4.0 console application. I am trying to read the data from MS excel 2007 document. (file format in Xlsx)

I use the below code to load the data into datatable. It works fine if all the cells have values. But it does not work when one of the column has blank values.

Data gets shifted to left in the datatable. I will want to fill blank value for the column "Code" in the datatable.

  Data in TestFile.xlsx
FULL NamePanIDPeriodYearCodeType
Name112013012013
1
Name222013022014
2
Name332013032015
3
Name442013042016
4

WindowsBase version 4.0 and DocumentFormat.OpenXML dll reference added

using DocumentFormat.OpenXml.Spreadsheet;
using DocumentFormat.OpenXml.Packaging;

public void Read2007Xlsx() { try { DataTable dt = new DataTable(); using (SpreadsheetDocument spreadSheetDocument = SpreadsheetDocument.Open(@"D:\2007\Testfile.xlsx", false)) { WorkbookPart workbookPart = spreadSheetDocument.WorkbookPart; IEnumerable<Sheet> sheets = spreadSheetDocument.WorkbookPart.Workbook.GetFirstChild<Sheets>().Elements<Sheet>(); string relationshipId = sheets.First().Id.Value; WorksheetPart worksheetPart = (WorksheetPart)spreadSheetDocument.WorkbookPart.GetPartById(relationshipId); Worksheet workSheet = worksheetPart.Worksheet; SheetData sheetData = workSheet.GetFirstChild<SheetData>(); IEnumerable<Row> rows = sheetData.Descendants<Row>(); foreach (Cell cell in rows.ElementAt(0)) { dt.Columns.Add(GetCellValue(spreadSheetDocument, cell)); } foreach (Row row in rows) //this will also include your header row... { DataRow tempRow = dt.NewRow(); for (int i = 0; i < row.Descendants<Cell>().Count(); i++) { // tempRow[i] = GetCellValue(spreadSheetDocument, row.Descendants<Cell>().ElementAt(i-1)); tempRow[i] = GetCellValue(spreadSheetDocument, row.Descendants<Cell>().ElementAt(i)); } dt.Rows.Add(tempRow); } } dt.Rows.RemoveAt(0); //...so i'm taking it out here. } catch (Exception ex) { } } public static string GetCellValue(SpreadsheetDocument document, Cell cell) { SharedStringTablePart stringTablePart = document.WorkbookPart.SharedStringTablePart; if (cell.CellValue ==null) { return ""; } string value = cell.CellValue.InnerXml; if (cell.DataType != null && cell.DataType.Value == CellValues.SharedString) { return stringTablePart.SharedStringTable.ChildElements[Int32.Parse(value)].InnerText; } else { return value; } }


How to identify if a cell has blank value while reading Xlsx file using Open XML?

How to convert data in Xlsx file into dataset that has blank values using Open XML?

Thanks
Ashok

Using Open XML SDK can we achieve all the functionality available in Microsoft.Office.Interop.Word

$
0
0

Hi EveryOne,

Good Evening . 

I am  using Microsoft.Office.Interop.Word to generate reports in Word Documents.

Now My requiremnet is to replace Microsoft.Office.Interop.Word  with OPEN XML SDK.

is it possible? is all the functionality available in OPEN XML SDK which is available in  Microsoft.Office.Interop.Word  .

I didn't find Range object equalent in OPen XML. and also for Selection.TypeParagraph()

Thanks in Advance

Yalamnchi

Enter Key functionality in Open XML SDK

$
0
0

How to get Enter Key functionality in Open XML SDK.

Enter key in word document goes to next line

how to insert a picture inside the table cell from excel to word document using openxml sdk

$
0
0

how to insert a picture inside the table cell from excel to word document using openxml sdk
and also how to increase the width and height of the particular cell and row using open xml

thanks !

Banupriya V K

Labs Of Open XML Trainning

$
0
0

I've been seeing the videos and I'm at WordProcessingML Basics video.

The main problem is that I can't find any of the labs mentioned in the trainning videos no matter how far I look at them.

http://msdn.microsoft.com/en-us/office/bb738430.aspx

Can anyone post the links to the labs and code used in the trainning please.

regards,

Victor

Add validation key/ signature to pptx file

$
0
0
I am writing my own PPTX file using Open Package Conventions. I want to add an internal unique signature to the file, which I can use to check if the file is correct and valid (something like a signature, but a private tag). Are there any recommendations on how I can do this?

using openxml writer to set up the width of the columns in excel

$
0
0

Hello

I am currently using the below example to write my excel file (my excel file has a lot of records).

I want to ask how I can use openxml writer to set up the width of the columns?

Here is the sample code.  can someone provide the solution of how to do it?

I tried to create columns class in between worksheet and sheetdata, but i have trouble create excel file.

Appreciate it! thanks.

using (SpreadsheetDocument xl = SpreadsheetDocument.Create("LargeFile.xlsx", SpreadsheetDocumentType.Workbook))
{
    List<OpenXmlAttribute> oxa;
    OpenXmlWriter oxw;

    xl.AddWorkbookPart();
    WorksheetPart wsp = xl.WorkbookPart.AddNewPart<WorksheetPart>();

    oxw = OpenXmlWriter.Create(wsp);
    oxw.WriteStartElement(new Worksheet());
    oxw.WriteStartElement(new SheetData());

    for (int i = 1; i <= 50000; ++i)
    {
        oxa = new List<OpenXmlAttribute>();
        // this is the row index
        oxa.Add(new OpenXmlAttribute("r", null, i.ToString()));

        oxw.WriteStartElement(new Row(), oxa);

        for (int j = 1; j <= 100; ++j)
        {
            oxa = new List<OpenXmlAttribute>();
            // this is the data type ("t"), with CellValues.String ("str")
            oxa.Add(new OpenXmlAttribute("t", null, "str"));

            // it's suggested you also have the cell reference, but
            // you'll have to calculate the correct cell reference yourself.
            // Here's an example:
            //oxa.Add(new OpenXmlAttribute("r", null, "A1"));

            oxw.WriteStartElement(new Cell(), oxa);

            oxw.WriteElement(new CellValue(string.Format("R{0}C{1}", i, j)));

            // this is for Cell
            oxw.WriteEndElement();
        }

        // this is for Row
        oxw.WriteEndElement();
    }

    // this is for SheetData
    oxw.WriteEndElement();
    // this is for Worksheet
    oxw.WriteEndElement();
    oxw.Close();

    oxw = OpenXmlWriter.Create(xl.WorkbookPart);
    oxw.WriteStartElement(new Workbook());
    oxw.WriteStartElement(new Sheets());

    // you can use object initialisers like this only when the properties
    // are actual properties. SDK classes sometimes have property-like properties
    // but are actually classes. For example, the Cell class has the CellValue
    // "property" but is actually a child class internally.
    // If the properties correspond to actual XML attributes, then you're fine.
    oxw.WriteElement(new Sheet()
    {
        Name = "Sheet1",
        SheetId = 1,
        Id = xl.WorkbookPart.GetIdOfPart(wsp)
    });

    // this is for Sheets
    oxw.WriteEndElement();
    // this is for Workbook
    oxw.WriteEndElement();
    oxw.Close();

    xl.Close();
}


How to find out Page Number to dsiplay in the footer section using Open XML

$
0
0

Hi Every One,

How  to find out Page Number to dsiplay in the footer section using Open XML

Thanks for the help .

Giri

Where is the table border width (wx:bdrwidth) stored in the OpenXML format?

$
0
0

Greetings!

So I created a table with a bottom border of thickness "3" and saved it in the Word 2003 XML (e.g. wordML) format, and this is the relevant part of the WordML (notice specifically this partwx:bdrwidth="60") :

<w:tblBorders>

<w:top w:val="single" w:sz="24" wx:bdrwidth="60" w:space="0" w:color="000000"/>

<w:bottom w:val="single" w:sz="24" wx:bdrwidth="60" w:space="0" w:color="000000"/>

</w:tblBorders>

Now when I do the same exact thing in Word 2010 and save it in OpenXML, the relevant part of the OpenXML looks like:

<w:tblBorders>

<w:top w:val="single" w:sz="24" w:space="0" w:color="000000"/>

<w:bottom w:val="single" w:sz="24" w:space="0" w:color="000000"/>

</w:tblBorders>


So as you can see above, there is no  wx:bdrwidth="60".So where is the border width stored?!

So I inspected the entire open XML output and couldn't find where it stores the border width information.  Am I missing something?  Can someone please point me in the direction of where this information is stored, I need to do an XSLT to HTML and I need to know the border widths to render appropriately but can't find them.

Thank you in advance,



Khalid K.

Is this possible to do redact the contents of the word 2007 documents?

$
0
0

Hi All,

         I am manipulating Word 2007/2010 documents in C# through the help of Open XML SDK 2.0(Add,delete,Upate Word paragraphs) successfully.I have downloaded the Word 2007/2010 Redaction tool plug-in  for my word 2007.It is working fine with Manually. 

Now i want to do the redaction work programatically in C#.Can i access and do the functionalities of this plug-in through C# code using open xml sdk 2.0 or 2.5? If possible send me some sample code for me..

Or 

You can also suggest me a alternative idea about "redact  the contents of the WORD 2007 Documents through C#" ....

2) Is there any web viewer available for viewing word 2007 documents in browser...? or is it possible with open xml sdk 2.5?

Thanks in Advance...!!!


Opening WordprocessingDocument causes System.UriFormatException

$
0
0

I have a .docx document which contains only the next hyperlink:

http://www.test,com/

I am trying to open it usin OpenXml SDK with the next code (VB.Net):

Dim DocAs WordprocessingDocument

Doc = WordprocessingDocument.Open(InputFileName,True)

 

 

For this document it always results with the next exception:

System.UriFormatException: Invalid URI: The hostname could not be parsed.

   at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind)

   at System.Uri..ctor(String uriString, UriKind uriKind)

   at MS.Internal.IO.Packaging.InternalRelationshipCollection.ProcessRelationshipAttributes(XmlCompatibilityReader reader)

   at MS.Internal.IO.Packaging.InternalRelationshipCollection.ParseRelationshipPart(PackagePart part)

   at MS.Internal.IO.Packaging.InternalRelationshipCollection..ctor(Package package, PackagePart part)

   at System.IO.Packaging.PackagePart.EnsureRelationships()

   at System.IO.Packaging.PackagePart.GetRelationshipsHelper(String filterString)

   at System.IO.Packaging.PackagePart.GetRelationships()

   at DocumentFormat.OpenXml.Packaging.OpenXmlPart.Load(OpenXmlPackage openXmlPackage, OpenXmlPart parent, Uri uriTarget, String id, Dictionary`2 loadedParts)

   at DocumentFormat.OpenXml.Packaging.OpenXmlPartContainer.LoadReferencedPartsAndRelationships(OpenXmlPackage openXmlPackage, OpenXmlPart sourcePart, PackageRelationshipCollection relationshipCollection, Dictionary`2 loadedParts)

   at DocumentFormat.OpenXml.Packaging.OpenXmlPackage.Load()

   at DocumentFormat.OpenXml.Packaging.OpenXmlPackage.OpenCore(String path, Boolean readWriteMode)

   at DocumentFormat.OpenXml.Packaging.WordprocessingDocument.Open(String path, Boolean isEditable, OpenSettings openSettings)

   at DocumentFormat.OpenXml.Packaging.WordprocessingDocument.Open(String path, Boolean isEditable)

 

Could anyone help me with this?

 

Problems with creating a new presentation from potx file

$
0
0

Hi

In one of my projects I create a new powepoint presentation from a Powerpoint template file (POTX).

So far the project creates a presentation where I can set document and core properties without problem, but when I try to add a slide from another presentation in the process I get errors because the PPTX-file created contains no slides.

I use the followng funtion to create the new presentation from a template:

Public Function PTCreatePowerpointPres(ByVal templatePath As String, ByVal presPath As String) As String Dim oldCulture As Globalization.CultureInfo = System.Threading.Thread.CurrentThread.CurrentCulture System.Threading.Thread.CurrentThread.CurrentCulture = New System.Globalization.CultureInfo("en-US") File.Copy(templatePath, presPath, True) File.SetAttributes(presPath, FileAttributes.Normal) Using pres As PresentationDocument = PresentationDocument.Open(presPath, True) pres.ChangeDocumentType(PresentationDocumentType.Presentation) End Using System.Threading.Thread.CurrentThread.CurrentCulture = oldCulture Return presPath

End Function


If I compare the resulting XML-code with a manually created presentation using Powerpoint 2010 a get two differences:

Difference 1

and

Difference 2

I have looked around for any help on this, but every sample assumes there already exists one or more slides in the presentation.

Any help is much appreciated

Thanks in advance


Best Regards Peter Karlström Midrange AB, Sweden

Where to add a SharedStringTablePart to OpenXmlReader/OpenXmlWriter?

$
0
0

I'm trying to write a spreadsheet using the SAX method (to save memory) as per this MSDN blog posting and I'm trying to write text to most of the cells. I'm new to this but evidently I can't just add the text to the cell - that would be too easy - so I have to write to a SharedStringTablePart, but I have no idea where to actually save this to the file using the SAX method.

Do does anybody know how I can assign a SharedStringTablePart to the OpenXmlReader or OpenXmlWriter or whether I have to add this to the spread sheet in some other way? I have to use the SAX method due to memory constraints on the web server, and most examples I've seen assume you're just using the DOM method, which is out of the question.

Thanks.



Is it Possible to print word document using Open XML

$
0
0

Hi EveryOne

Is it Possible to print word document using Open XML?

Having a problem with italics

$
0
0

Hello,

I'm facing a problem adding italics to a paragraph, in the creation of a word document,

This is my code(similar to the msdn example for adding bold/italics):


var tr = new TableRow(); var tcTime = new TableCell();

var textRun = new Run();
textRun.Append(new Text("Test"));

var runProperties = new RunProperties(new Italic()); tcText.Append(new Paragraph(runProperties, textRun)); tcText.Append(new TableCellProperties(new TableCellWidth { Type = TableWidthUnitValues.Pct, Width = "45%" })); tr.Append(tcText); table.Append(tr);

What am i doing wrong here?


thank you very much in advance!

jony.

Regarding Office Open XML for Office 2010

$
0
0

Hello,

I want to detect the formatting changes like (left, right, center alignment) of the cells in Excel 2010, detect keyboard shortcuts and detecting currency like "$" done in Excel 2010. Can I use OOXML to detect these changes? If yes, how to do it?

Thanks,

Priyanka

Getting hash and digital signature generated out of band

$
0
0

Hi,

I know OpenXML SDK can be used to create signature lines Is it possible to create reference hashes and digital signature out of band just like the SignatureProvider (COM add-in) design provides so some thing like as handlers are configured and the business application can work on the hash + Signature part (PKCS#1) where as OpenXML SDK works on the packaging part. I have looked at the Packaging API as well but it only works with windows key stores.

If this functionality is not supported then should I be expecting this to be present in the near future

Thanks,

Wahaj

Number in this cell is formatted as text or preceded by apostrophe

$
0
0

Hey

I am working with excel sheet using openxml in c#. I have inserted numbers(converted to string)  in excel sheet. But In excel sheet I am getting the error "Number in this cell is formatted as text or preceded by apostrophe".  I want to insert numbers in form of text. How can i ignore this error programmatically so that it doesn't show any error.

I have studied about numberformats to remove this error. But I don't know how to use it. Please help.

Thanks


Viewing all 1288 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>