openxml

Is this correct Open Office XML?

↘锁芯ラ 提交于 2019-12-13 13:15:47
问题 <?xml version="1.0" encoding="UTF-8" standalone="yes" ?> <?mso-application progid="Word.Document"?> <pkg:package xmlns:pkg="http://schemas.microsoft.com/office/2006/xmlPackage"> <pkg:part pkg:name="/_rels/.rels" pkg:contentType="application/vnd.openxmlformats-package.relationships+xml" pkg:padding="512"> <pkg:xmlData> <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"> <Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006

OpenXML - change Excel cell format (Date and Number) when exporting from Datagridview

假如想象 提交于 2019-12-13 12:50:22
问题 I using OpenXML to export Datagridview to Excel. If I export cells with CellValues.String evertyhing works fine without any errors in Excel file, but what I need is to properly convert all Date and Number data into corresponding cell format. I've tried to use built-in formats (not custom ones) to change format of cells, but then my Excel got corrupted. Here is what I tried so far: public void Export_to_Excel(DataGridView dgv, string path) { using (var workbook = SpreadsheetDocument.Create

Extract XML using OPENXML()

微笑、不失礼 提交于 2019-12-13 11:07:58
问题 My problem is that I do not know how to extract the XML tag element using OpenXML. Any clarification would be great. I have using xml.node before but now I am transitioning to OpenXML My XML document can be found here My Stored procedure: ALTER procedure [dbo].[WEEKXml] (@xmlstr ntext) as begin declare @hDoc int exec sp_xml_preparedocument @hDoc OUTPUT,@xmlstr insert into tbl_weekquake select xml.time,xml.longitude,xml.latitude,xml.depth,xml.mag,xml.type,xml.description,xml.text from OPENXML(

How to add OpenXml list paragraph with bullets to content control?

只谈情不闲聊 提交于 2019-12-13 09:31:18
问题 Im using a Word 2013 .docx as a template thats opened in the openxml code, the content controls are filled in then its saved, downloaded to the user and that part works fine. In one content control the goal is to add a bulleted list. The problem comes from trying to append or replace the new paragraph, which is generated from a method. This method works fine, i send it the variable and it returns a paragraph with a bullet. It inserts, but it corrupts the word doc; Shown below are the template

Exporting huge xml to excel using Openxml

可紊 提交于 2019-12-13 09:10:27
问题 I tried to write a big transformed xml data to excel using openxml sdk 2.0..its given me a big exception.i think the Open xml is not supportive to write the bulk data to excel..i was able to write 50000 rows. this is my code:: public void AddPartXml(OpenXmlPart part, string xml) { using (Stream stream = part.GetStream()) { byte[] buffer = (new UTF8Encoding()).GetBytes(xml); stream.Write(buffer, 0,buffer.Length); stream.Dispose(); } } Is there any possibility that we can write data to exce in

Adding spacing and blank lines to Open Office XML

狂风中的少年 提交于 2019-12-13 05:57:54
问题 I am trying to output a word file using Open Office XML, but can't seem to get spacing correct. Variable name:ATTEND Description:Student's attendance status during the I want the word file to be this (with spaces after the :): Variable name: ATTEND Description:Student's attendance status during the My code is as follow, and the spacing disappears: start of my function // Add a new main document part. MainDocumentPart mainPart = wordDocument.AddMainDocumentPart(); // Create the Document DOM.

Importing and parsing a large XML file in SQL Server (when “normal” methods are rather slow)

无人久伴 提交于 2019-12-13 05:16:22
问题 I have a large XML file that I need to import and parse into tabular structure ("flatten") in SQL Server. By "large" I mean a file that is around 450 MB, contains up to 6-7 nested levels and lots of elements, ~300. I tried parsing the file both with OPENXML and Xml.Nodes . Both of the methods are slow. A partial query which reads a parent element and it's nested grandchildren takes several minutes if not dozens to run. I tried using the SQLXML Bulk Load method. Unfortunately I couldn't -

Exporting to Excel (OpenXML) results in Unreadable Content

可紊 提交于 2019-12-13 05:14:42
问题 I've been struggeling with creating worksheets for my xlsx file. Adding the first worksheet isn't a problem, but when I want a second sheet, the exported xlsx seems to be corrupt. Who can point out to me what I'm doing wrong? Note: I already tried to also call 'workbookpart,Workbook.Save();' right after creating the first Workbook, but without the required result. protected void export_Click(object sender, EventArgs e) { ExportToExcel(@"D:\dev\Dotnet4\Excel\test.xlsx"); } private void

Get Index of last active columns per Row in Excel using Open XML

有些话、适合烂在心里 提交于 2019-12-13 05:04:31
问题 How do i get the Index of the last active column in a row using Open Xml i have this for row 1. Dim activeCells As IEnumerable(Of DocumentFormat.OpenXml.Spreadsheet.Cell) = row.Descendants(Of DocumentFormat.OpenXml.Spreadsheet.Cell)().Where(Function(c) Not String.IsNullOrEmpty(c.InnerText)) Dim cell As DocumentFormat.OpenXml.Spreadsheet.Cell = activeCells.LastOrDefault() Dim CellRef As String = cell.CellReference This gives D1", but what i want is the index in this case "4". how do i go about

Relationship error when trying to embed and image into a Word document

巧了我就是萌 提交于 2019-12-13 04:58:42
问题 I add a PNG image to a word 2010 document like this: var imagePart = report.MainDocumentPart.AddImagePart(ImagePartType.Png); var imagePath = Path.Combine(imageFolder, "1.png"); var stream = new FileStream(imagePath, FileMode.Open); imagePart.FeedData(stream); stream.Close(); I find the blip element of an empty Picture content control and change its reference property to point to the new image: var blip = image.Descendants<Blip>().Single(); blip.Embed = report.MainDocumentPart.GetIdOfPart