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

Direct edit of Word Building Blocks

$
0
0
I know the building blocks saved to MS Word are saved to the file at C:\Documents and Settings\<<username>>\Application Data\Microsoft\Document Building Blocks\1033\Building Blocks.dotx
(or Vista C:/Users/<<username>>/AppData/Roaming/Microsoft/Document Building Block).

Now I would like to edit the building blocks directly, not their properties, but the building blocks themselves. I would liek to edti them directly, because whenever i need to update one of my building blocks i currently have to delete the old building block entry, then create the updated building block somewher in word and then go and save the building block again. Instead of this indirect method, i would like to edit teh Building Blocks.dotx file directly , save it and have my updates done without the extra delete and readd hassle.

But when i open Building Blocks.dotx as Open template, it is empty? i dont see any building blocks i could edit? how are the building blocks saved into Building Blocks.dotx and most importantly is there any way to edit them directly?

thanks for your help.

Access an Open XML file on OneDrive to specific data

$
0
0

I trying to find information on how to access a Open XML file on a OneDrive or SharePoint folder using a service. The idea is to pass access information such as userID and password to the OneDrive or SharePoint, open the Excel(xlsx) or Word(docx) and search the xml parts for nodes to bring back specific items for use in an Office Web application. Can someone direct me to examples or step by step how tos?  Also I remember reading or being told the service would have to exist on an Azure server to access the OneDrive or SharePoint servers,  is that correct?

Thank you

Jim

Render HTML inside Excel, using Open XML

$
0
0

Hello guys,

I am creating excel file using, Open XML.

The data will be coming from database, and can contain HTML tags.

e.g. <b>some sample <i style='color:red'> text </i></b>

I want the HTML to be rendered inside excel sheet, so that user can view well formatted excel..

Please, Help me out


Placeholder shapes when inserting slide programmatically

$
0
0

Hello,

I recently starte dwriting code to create an OpenXML presentation from some content. Everything is working so far.

The only thing I am not able to solve:

I am inserting a new slide and connecting to an existing slide layout part, like:

SlideLayoutPart slideLayoutPart = null;
foreach (var layoutPart in masterPart.SlideLayoutParts.Where(layoutPart => layoutPart.SlideLayout.CommonSlideData.Name.Value.Equals(layout))))
     slideLayoutPart = layoutPart;

if (slideLayoutPart != null)
{
     slidePart.AddPart(slideLayoutPart);
     newSlide = new Slide { CommonSlideData = (CommonSlideData)slideLayoutPart.SlideLayout.CommonSlideData.Clone() };
     using (var stream = slideLayoutPart.GetStream())
     {
          slidePart.SlideLayoutPart.FeedData(stream);
     }
}
newSlide.save(slidePart);

But when I open the presentation, the placeholder shapes in the slidelayout are not rendered correctly.

When I add a new slide in powerpoint, I get those placeholder shapes where the text flushes when I place the cursor, so I can fill with my own text. 

But adding a slide programmatically like shown above, the placeholder text is rendered as normal text.

My question: How to remain the placeholders correctly? 

Thanks!

Apply style not working

$
0
0

I have 2 docx files, one contains the styles I want to use.

The other one needs to get these styles. (I believe this is working)

But in the second file I also need to find paragraphs that contain <H1> or <H2> etc.

I can find the paragraphs , but when I then apply a style to it (Heading 1, Heading 2 etc) I don't see anything happening in

the final document. I believe the styles are in the document, just the 'apply' does not seem to do anything.I also look for <TOC> and insert a TOC at that location, that works fine, but the styling...is a problem.

The full example (C#) can be downloaded from http://www.geerdes.nl/openxml.zip

In the debug directory you will find the FileC.docx, styles.docx that I use.

I really could use some help here.

Thanks in advance

  Ben

private void button1_Click(object sender, EventArgs e)
{    WordprocessingDocument styleDocument = WordprocessingDocument.Open(@"styles.docx"true);    byte[] byteArray = File.ReadAllBytes(@"FileC.docx");    MemoryStream stream = new MemoryStream();    stream.Write(byteArray, 0, (int)byteArray.Length);    WordprocessingDocument wordDocument = WordprocessingDocument.Open(stream, true);    Dictionary<StringStyle> dictstylesin = new Dictionary<stringStyle>();    Dictionary<StringStyle> dictstylesout = new Dictionary<stringStyle>();    var node = WDExtractStyles(styleDocument, false);    if (node != null)        WDReplaceStyles(wordDocument, node, false);    StyleDefinitionsPart styleDefinitionsPartIn =            styleDocument.MainDocumentPart.StyleDefinitionsPart;    Styles stylesin = styleDefinitionsPartIn.Styles;    String headername = "Heading";        StyleDefinitionsPart styleDefinitionsPartOut = wordDocument.MainDocumentPart.StyleDefinitionsPart;    // If the Styles part does not exist, add it and then add the style.    if (styleDefinitionsPartOut == null)    {        styleDefinitionsPartOut = wordDocument.MainDocumentPart.AddNewPart<StyleDefinitionsPart>();        Styles root = new Styles();        root.Save(styleDefinitionsPartOut);    }    Styles stylesout = styleDefinitionsPartOut.Styles;    foreach (var st in stylesout)    {        if (st is DocumentFormat.OpenXml.Wordprocessing.Style)        {            dictstylesout.Add(((DocumentFormat.OpenXml.Wordprocessing.Style)st).StyleName.Val.ToString(), ((DocumentFormat.OpenXml.Wordprocessing.Style)st));            if (((DocumentFormat.OpenXml.Wordprocessing.Style)st).StyleId.ToString().ToLower().Contains("kop"))            {                headername = "Kop";            }        }    }    foreach (OpenXmlElement ox in wordDocument.MainDocumentPart.Document.Body.Descendants().Where(x => x is Text && x.InnerText.Contains("<H1>")))    {        Run run = (Run)ox.Parent;        Paragraph p = (Paragraph)run.Parent;        ApplyStyleToParagraph(wordDocument, headername + "1""heading 1", p);    }    foreach (OpenXmlElement ox in wordDocument.MainDocumentPart.Document.Body.Descendants().Where(x => x is Text && x.InnerText.Contains("<H2>")))    {        Run run = (Run)ox.Parent;        Paragraph p = (Paragraph)run.Parent;        ApplyStyleToParagraph(wordDocument, headername + "2""heading 2", p);    }    foreach (OpenXmlElement ox in wordDocument.MainDocumentPart.Document.Body.Descendants().Where(x => x is Text && x.InnerText.Contains("<H3>")))    {        Run run = (Run)ox.Parent;        Paragraph p = (Paragraph)run.Parent;        ApplyStyleToParagraph(wordDocument, headername + "3""heading 3", p);    }    // Inserts a TOC with a different title        XElement firstPara = wordDocument            .MainDocumentPart            .GetXDocument()            .Descendants(W.p)            .Where( y => y.Value.ToLower().Contains("<toc>")).FirstOrDefault();    if (firstPara != null)    {        TocAdder.AddToc(wordDocument, firstPara,                @"TOC \o '1-3' \h \z \u", firstPara.Value.Replace("<TOC>","").Replace("<toc>",""), null);        firstPara.RemoveAll();    }    OpenXmlElement para = wordDocument.MainDocumentPart.Document.Body.Descendants().Where(x => x is Text && x.InnerText.Contains("<TOC>")).FirstOrDefault();    if (para != null)    {        Run run = (Run)para.Parent;         Paragraph p = (Paragraph)run.Parent;        p.InnerXml = "";        p.RemoveAllChildren();         p.Remove();     }    wordDocument.MainDocumentPart.PutXDocument();    wordDocument.MainDocumentPart.StyleDefinitionsPart.PutXDocument();    wordDocument.MainDocumentPart.DocumentSettingsPart.PutXDocument();     File.WriteAllBytes("newFile.docx", stream.ToArray());    styleDocument.Dispose();    wordDocument.Dispose();        
}// Add a StylesDefinitionsPart to the document.  Returns a reference to it.public static StyleDefinitionsPart AddStylesPartToPackage(WordprocessingDocument doc)
{    StyleDefinitionsPart part;    part = doc.MainDocumentPart.AddNewPart<StyleDefinitionsPart>();    Styles root = new Styles();    root.Save(part);    return part;
}// Return true if the style id is in the document, false otherwise.public static bool IsStyleIdInDocument(WordprocessingDocument doc,    string styleid)
{    // Get access to the Styles element for this document.    Styles s = doc.MainDocumentPart.StyleDefinitionsPart.Styles;    // Check that there are styles and how many.    int n = s.Elements<Style>().Count();    if (n == 0)        return false;    // Look for a match on styleid.    Style style = s.Elements<Style>()        .Where(st => (st.StyleId == styleid) && (st.Type == StyleValues.Paragraph))        .FirstOrDefault();    if (style == null)        return false;    return true;
}// Apply a style to a paragraph.public static void ApplyStyleToParagraph(WordprocessingDocument doc,    string styleid, string stylename, Paragraph p)
{    // If the paragraph has no ParagraphProperties object, create one.    if (p.Elements<ParagraphProperties>().Count() == 0)    {        p.PrependChild<ParagraphProperties>(new ParagraphProperties());    }    // Get the paragraph properties element of the paragraph.    ParagraphProperties pPr = p.Elements<ParagraphProperties>().First();    // Get the Styles part for this document.    StyleDefinitionsPart part =        doc.MainDocumentPart.StyleDefinitionsPart;    // If the style is not in the document, add it.    if (IsTheStyleIdInDocument(doc, styleid) != true)    {        // No match on styleid, so let's try style name.        string styleidFromName = GetStyleIdFromStyleName(doc, stylename);        styleid = styleidFromName;    }    // Set the style of the paragraph.    pPr.ParagraphStyleId = new ParagraphStyleId() { Val = styleid };
}// Return true if the style id is in the document, false otherwise.public static bool IsTheStyleIdInDocument(WordprocessingDocument doc,    string styleid)
{    // Get access to the Styles element for this document.    Styles s = doc.MainDocumentPart.StyleDefinitionsPart.Styles;    // Check that there are styles and how many.    int n = s.Elements<Style>().Count();    if (n == 0)        return false;    // Look for a match on styleid.    Style style = s.Elements<Style>()        .Where(st => (st.StyleId == styleid) && (st.Type == StyleValues.Paragraph))        .FirstOrDefault();    if (style == null)        return false;    return true;
}// Return styleid that matches the styleName, or null when there's no match.public static string GetStyleIdFromStyleName(WordprocessingDocument doc, string styleName)
{    StyleDefinitionsPart stylePart = doc.MainDocumentPart.StyleDefinitionsPart;    string styleId = stylePart.Styles.Descendants<StyleName>()        .Where(s => s.Val.Value.Equals(styleName) &&            (((Style)s.Parent).Type == StyleValues.Paragraph))        .Select(n => ((Style)n.Parent).StyleId).FirstOrDefault();    return styleId;
}public static void WDReplaceStyles(WordprocessingDocument document,    XDocument newStyles,    bool setStylesWithEffectsPart = true)
{    var docPart = document.MainDocumentPart;    StylesPart stylesPart = null;    if (setStylesWithEffectsPart)        stylesPart = docPart.StylesWithEffectsPart;    else        stylesPart = docPart.StyleDefinitionsPart;    if (stylesPart != null)    {        newStyles.Save(new StreamWriter(stylesPart.GetStream(            FileMode.Create, FileAccess.Write)));    }
}public static XDocument WDExtractStyles(         WordprocessingDocument document,        bool getStylesWithEffectsPart = true)
{    XDocument styles = null;    var docPart = document.MainDocumentPart;    StylesPart stylesPart = null;    if (getStylesWithEffectsPart)        stylesPart = docPart.StylesWithEffectsPart;    else        stylesPart = docPart.StyleDefinitionsPart;    if (stylesPart != null)    {        using (var reader = XmlNodeReader.Create(            stylesPart.GetStream(FileMode.Open, FileAccess.Read)))        {            // Create the XDocument:            styles = XDocument.Load(reader);        }    }    return styles;
}

Error -2147417851 Method '~' of object '~' failed in VB6 with word 2003

$
0
0

We have very strange error here for which we could not find any solution. I hope VB6 ,word expert could help us in this.

We have our code in VB6. There is a functionality in the code in which we send the word documents to client/users through the code. Word documnets have bookmarks in them. During send operation code creates word object, generates the bookmarks in the ActiveDocument and send it to client.

However, users are getting below error while sending the documents. We have tried tried users scenarios in our local machines the error does not get reproduced. Below is the error description through the log for the user.

Error Description -2147417851 Method '~' of object '~' failed

Source     RevisionDLL     CGCDocWordApp:ActiveBookmarkSet Method
RevisionDLL     CGCDocWordApp:GetNextTypeBookmark Method
RevisionDLL     IDocument:GenerateDocument Method
DistribDll     IDistribution::PrepareDoc

Note: The error occuring when the documents are in bunch. and the error is inconsistent. We checked the MDAC version of all servers. MDAC version are matching

Which googled around for all possible solutions but neither solution is working for us.

what's the difference between "ApplyFill=true" and "ApplyFill=false"

$
0
0

hi,

In the excel document,  the following three seems the same, what is the difference?

1) <xf numFmtId="0" fontId="0" fillId="2" borderId="0" xfId="0" applyFill="1">...  //CellFormat.ApplyFill=true

2) <xf numFmtId="0" fontId="0" fillId="2" borderId="0" xfId="0" >...                         //CellFormat.ApplyFill=null

3) <xf numFmtId="0" fontId="0" fillId="2" borderId="0" xfId="0" applyFill="0">...  //CellFormat.ApplyFill=false

thanks,

Jialinhai

Convert into Data Table issue from Excel Sheet Table

$
0
0

Hi 

i've excel file where 10-12 sheets are available in that excel file.one of the sheet is named as summary.there are 8-10 tables(named as Table1,Table2,Table3....) in that summary sheet as well. 

i've to actually get the Table1 from the summary sheet into the DataTable. 

So,i've written a following method to read "summary" sheet and then i checked if the Table1 exist then break the loop.My problem is i've found Table1 but i am not able to convert it into the DataTable.Can anyone tell me how to do it.

private void GetProjectTable(string ExcelFileUrl)
{
            string sheetName = "Summary";
            string value = null;

            // Open the spreadsheet document for read-only access.
            try
            {
                String siteURL = SPContext.Current.Site.Url;
                SPSecurity.RunWithElevatedPrivileges(delegate()
                {
                    Stream dataStream = null;
                    using (SPSite site = new SPSite(siteURL))
                    {
                        using (SPWeb web = site.OpenWeb())
                        {
                            SPFile file = web.GetFile(ExcelFileUrl);
                            dataStream = file.OpenBinaryStream();

                            using (SpreadsheetDocument document =
                                  SpreadsheetDocument.Open(dataStream, false))
                            {
                                // Retrieve a reference to the workbook part.
                                WorkbookPart wbPart = document.WorkbookPart;
                                Sheet theSheet = wbPart.Workbook.Descendants<Sheet>().
                              Where(s => s.Name == sheetName).FirstOrDefault();

                                // Throw an exception if there is no sheet.
                                if (theSheet == null)
                                {
                                    throw new ArgumentException("sheetName");
                                }

                                WorksheetPart wsPart =
                                (WorksheetPart)(wbPart.GetPartById(theSheet.Id));

                                DocumentFormat.OpenXml.Spreadsheet.Table table = null;
                                DataTable dt = null;

                                foreach (TableDefinitionPart tdp in wsPart.TableDefinitionParts)
                                {
                                    if (tdp.Table.DisplayName == "Table1")
                                    {
                                        table = tdp.Table;

                                        break;
                                    }
                                }
                            }
                        }
                    }
                });
            }
            catch (Exception ex)
            {


            }

}

Note: I am using this code in the Visual Web Part for SharePoint


How to get Document.OpenXML Version=2.5.5631.0 ?

$
0
0

Hi

I am trying to have Document.OpenXML Version=2.0.5022.0 because i am having this error when i try to run my project;

'ClosedXML, Version=0.76.0.0, Culture=neutral, PublicKeyToken=fd1eb21b62ae805b' uses

'DocumentFormat.OpenXml, Version=2.5.5631.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'

which has a higher version than referenced assembly

'DocumentFormat.OpenXml, Version=2.0.5022.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'

Do i need to get Document.open.xml Version=2.0.5022.0 , if so , how can i find this dll?

[if you provide a download link that would be great ..]

Thanks


Replacing InnerText in OpenXml SDK 2.0

$
0
0

Hi,

I'm using open xml SDK 2.0 and i'm kind off new to this.

I have actually created a quickpart (containg content control) in my word 2007 document named "hello.docx". Now I need to copy the quickpart into the other location of the same document named "hello.docx". I was very thank full for this post http://www.techques.com/question/1-3448297/Replacing-Content-Controls-in-OpenXML .This post just deletes the content control but keeps the content in Content control.

With the help of the above link I was able to modify the code to clone the content control and append to the same document (This part of my code is working). But i have problem in innerText. Though i replace the innerText in the open Xml element, it is not geting reflected in the document.

staticvoid AddingSdtBlock(string filename, string sdtBlockTag)
    {using (WordprocessingDocument doc = WordprocessingDocument.Open(filename,true))
      {
        MainDocumentPart mainDocumentPart = doc.MainDocumentPart;
        List<SdtBlock> sdtList = mainDocumentPart.Document.Descendants<SdtBlock>().ToList();
        SdtBlock sdtA = null;foreach (SdtBlock sdt in sdtList)
        {if (sdt.SdtProperties.GetFirstChild<Tag>().Val.Value == sdtBlockTag)
          {
            sdtA = sdt;break;
          }
        }
        SdtBlock cloneSdkt = (SdtBlock)sdtA.Clone();
        OpenXmlElement sdtc = cloneSdkt.GetFirstChild<SdtContentBlock>();// OpenXmlElement parent = cloneSdkt.Parent; 
        OpenXmlElementList elements = cloneSdkt.ChildElements;// var mySdtc = new SdtContentBlock(cloneSdkt.OuterXml); foreach (OpenXmlElement elem in elements)
        {string innerxml= elem.InnerText ;if (innerxml.Length>0)
         {string modified = "Class Name : My Class.Description : mydesc.AttributesNameDescriptionMy Attri name.my attri desc.Operations NameDescriptionmy ope name.my ope descriptn.";string replace= elem.InnerText.Replace(innerxml, modified);// mainDocumentPart.Document.Save(); 
         }// string text = parent.FirstChild.InnerText; // parent.Append((OpenXmlElement)elem.Clone()); 
        }
        mainDocumentPart.Document.Body.AppendChild<SdtBlock>(cloneSdkt);//sdtA.Remove(); 
      }
    }


 

The Replaced string in the openXML element is not geting reflected in the document. Any help would be really appreciated.

Thanks in advance,

Replace content controls in Table

$
0
0

Hi Everybody, 

I have a list of items, which should be nicely inserted into a word Table. 

The list is: 

Name: Test, SurName: Beta, Born: 10-01-2013, Nationality: Danish

Name: Test2, SurName: Beta2, Born: 10-01-2013, Nationality: Danish
Name: Test3, SurName: Beta3, Born: 10-01-2013, Nationality: Danish

I have created a content control for the whole table, one for the row and 4 content controls for the 4 items. 

How can I do this in C#?



Thanks in advance

Is this code to find and read a table from a spreadsheet correct?

$
0
0

Good morning!  This code took a while to put together - both cause I'm new to the OpenXML API, and because it's really hard to search for "table" and "spreadsheet" on the internet and not get results polluted by generic information on spreadsheets.  The background here is that I'm using SQL Server Integration Services to read Excel spreadsheets, and I got tired of the limitations in the COM API (bitness, type inference, etc...)

What follows is a redacted form of the code I have (no need to distract with SSIS and my internal structures).  Can you guys tell me if this code is a reliable method of reading a table?  if there are smallish tweaks I could make to make it more reliable, robust, future-proof?  OpenXML API specific things!  (I'm not looking for try/catch type improvements, I've redacted those.)

Some specific concerns of mine (but please comment on anything else) - is the way I'm using the "columnOffset" reliable?  I tried the column's ID, but that's not reliable if columns are inserted into the table.  Is there a built-in cell reference conversion function?  Instead of my CellReferenceToCoordinates function?

Thanks in advance!

SpreadsheetDocument document = SpreadsheetDocument.Open("File.xlsx", false);
WorkbookPart workbook = document.WorkbookPart;
SharedStringTablePart sharedStringTablePart = workbook.SharedStringTablePart;
Table table = null;
Worksheet worksheet = null;
string tableIAmLookingFor = "People";
string columnIAmLookingFor = "Last Name";
int columnOffset;

// Find the table, and the sheet it's on
foreach (Sheet sheet in workbook.Workbook.Sheets)
{
  WorksheetPart worksheetPart = (WorksheetPart)document.WorkbookPart.GetPartById(sheet.Id);
  foreach (TableDefinitionPart tableDefinitionPart in worksheetPart.TableDefinitionParts)
  {
    if (tableDefinitionPart.Table.DisplayName == tableIAmLookingFor)
    {
      worksheet = worksheetPart.Worksheet;
      table = tableDefinitionPart.Table;
      break;
    }
  }
  if (table != null)
  {
    break;
  }
}

// Read the table columns, find out where the column I'm interested in is in the table
int columnIndex = 1;
foreach (TableColumn tableColumn in table.TableColumns)
{
  foreach (ColumnMapping columnRelationship in this._columnMappings)
  {
    if (tableColumn.Name == columnIAmLookingFor)
    {
      columnOffset = columnIndex;
      break;
    }
  }
  columnIndex++;
}

// Read sheet data for values in the table
SheetData sheetData = worksheet.GetFirstChild<SheetData>();
IEnumerable<Row> rows = sheetData.Elements<Row>();
foreach (Row row in rows)
{
  if (row.RowIndex == 1)
  {
    // Skipping header row
  }
  else
  {
    // my app-specific code to handle the start of reading a "row" (redacted)
    foreach (Cell cell in row.Elements<Cell>())
    {
      // Next line refers to my own function that turns "B15" into {2, 5}
      if (this.CellReferenceToCoordinates(cell.CellReference)[0] == columnOffset)
      {
        string cellValue = this.GetCellValue(cell, sharedStringTablePart);
        // my app-specific code to handle cell value reading (redacted)
      }
    }
  }
}

document.Close();


Todd McDermid's BlogTalk to me now on

OPEN XML SDK

$
0
0

Hi ,

I am using degeree sing symbol in my word document.When open with OPEN XML SDK Editor it will display as a normal space.I want to determine degree symbol in document with OPEN XML SDK.How to identify that degree symbol.

Convert String a System.DateTime

$
0
0

Hi all,

I have an issue, there a column in an excel file that has format of date "02/19/2015" for example. But when I get that value in my code is a string "42569". How I can convert that value in System.Date for that show me the string as date"02/19/2015"

Thanks for your comments

pb for writing data in both Z and AA columns

$
0
0

Hello,

I manage to generate an Excel file with OpenXml but I have a blocking issue in one case.
Indeed, I can write data either : only between columns A and Z or between AA and above.
If I create a very simple sheet with a value in Z1 and a value in AA1, then my Excel file refuses to open and I have the error like there is unreadable content.

But, when I look at the content of the 2 generated files (one that works, the other not), I don't see any structure difference so I am lost...
For information, in order to look into details the content of my xlsx file, I move the extension from xlsx to zip, unzip the file, and I then have access to all the architecture of xml files.

So any idea why and how to workaround please?


How can I access revisions of a document using OpenXML sdk library?

$
0
0

How can I access revisions of a document using OpenXML sdk library?

Thanks in advance.

Regards,

Akanksha.

Get a specific column value as hyperlink in a excel sheet by using OpenXML in C#

$
0
0

Hi,

I am using OPEN XML option to export the records from a gridview to a spreadsheet. In the gridview in one of the column having a share path pdf/excel report , this path needs to get exported in the excel by marking that column value as hyperlink. 

I am new to this method please guide me on the same.

Note:- currently i am done with the export to excel using OPEN XML but waiting for the particular column value to be highlighted as hyperlink.


Ravi


How to delete a connection?

$
0
0

I am trying to create a snapshot from a full workbook downloaded from Excel services web service.  Excel services does not preserve page breaks so I am using OpenXML sdk to remove data connections from the workbook and copy/paste cell values over formulas.

All is well except that after deleting connections the workbook throws the "unreadable content" error when the user opens it in excel.  The workbook still opens and the repair message says the "connections.xml" file was repaired. The code I am using is:

     For i As Integer = wbPart.ConnectionsPart.Connections.Count - 1 To 0 Step -1
                   Dim conn As Connection = wbPart.ConnectionsPart.Connections(i)
                   conn.Deleted = True
             Next

This works fine to delete the connections, but obviously something else is required to maintain workbook integrity.  Is there another attribute of the connection node I should be changing or some other part of the workbook to update after deleting a connection?  Thanks in advance,  Marcus


scholz

Open XML 2.5 WordDocument: How to embed a font file in document and then reference it?

$
0
0

I have made good progress on creating Word documents including embedding images, tables, hyperlinks, and font styling. But now I need to embed non-standard fonts files into the document, and then have a run that uses them.

Anyone with clues?  Bonus points for example c# code.


Tim Mangan MVP for App-V and Citrix CTP Author of AppV books: "The Client Book" and "OSD Reference Book" (http://www.tmurgent.com/Books )


Why does Open XML API Import Text Formatted Column Cell Rows Differently For Every Row?

$
0
0
I am working on an ingestion feature that will take a strongly formatted .xlsx file and import the records to a temp storage table and then process the rows to create db records.  One of the columns is strictly formatted as "Text" but it seems like the Open XML API handles the columns cells differently on a row-by-row basis.  Some of the values while appearing to be numeric values are truly not (which is why we format the column as Text since others true text) - some examples are "211377","211727.01", "209395.388", "209395.435", "309036.FP", "212767.TM" - what these values represent is not important but what happens is that some values (using the Open XML API v2.5 library) will be read in properly as text whether retrieved from the Shared Strings collection or simply from InnerXML property while others get sucked in as numbers with what appears to be appended rounding or precision.  For example the "211377", "211727.01","209395.435", "309036.FP", "212767.TM" all import exactly as they are in the spreadsheet but the "209395.388" value (shows exactly this way if you open the spreadsheet natively in Excel) is being pulled in as "209395.38800000001" (there are others that this happens to as well).  There seems to be no rhyme or reason to which values get messed up and which ones import fine.  What is really frustrating is that if I use the native Import feature in SQL Server Management Studio and ingest the same spreadsheet to a temp table this does not happen - so how is that the SSMS import can handle these values as purely text for all rows but the Open XML API cannot.
Viewing all 1288 articles
Browse latest View live


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