Export to word document Nested tables using DocX library in c#, can't open document - asp.net-mvc

I have created word document (.doc and .docx) using DocX library in .net c#. I have used nested tables in this word document. Now the problem is that, whenever I try to open this generated document, it gives warning message like this :
"We are sorry. We can;t open because we found a problem with its contents."
Getting this message if I click on Details button. :
"Ambiguous cell mapping encountered. Possible missing paragraph element. elements are required before every ".
If I do not use nested table and use single table then its working fine and not giving any warning message while opening that word document.
So, can anyone help me here to how avoid such warning problems if I have nested tables in generating word document using DocX library in .Net C#. ?
Thanks in advance.
Herin.

Related

Can't get the F# Word typeprovider to work for custom Word documents

I've downloaded the FSharp 3 Sample Pack and tried out the sample for the Word documents typeprovider which works fine in the TestScript.fsx file when using the provided sample document (AA.docx). But when I try using it with a different Word document it doesn't work i.e. no properties are generated on the type provider instance (Person, MyCompany etc.). Even if I create a new document and copy the contents of AA.docx to it (keeping source formatting) it doesn't work. What could be the issue?
The word type provider uses the Open xML API. The same word content can have different XML representation at backend. I'd suggest you to download the Open XML SDK and use the tool to visualize its content.

Export data to XLS (not via CSV) on iOS

I need to export some data to an .XLS file, pdf, and print.
I already tried the simple solution: exporting it to .CSV with CHCSVWriter. It works for printing and saving it to pdf (I open the CSV in a UIWebView and get the PDF or print from there). However, to use the CSV to be open in excel has two main problems:
1 - First, as the name says, in the CSV the values are separated by commas, and in some versions of Excel, it requires the user to separate 'manually' in cells.
2 - I have hebrew characters, and I already tried all the string encodings, and can't have both hebrew and latin characters.
So, after giving up after days of trying to use CSV to solve the issues above, I gave up. How can I export my data to XLS?
The LibXL library provides this functionality for both xls and xlsx formats. There is no iOS version, but people say the iOS version is coming. You may want to contact LibXL support to confirm this.
EDIT:
The iOS version is available now.
This article explains how to programmatically create an Excel (.xls) file without using any external library. It just opens a file stream and it writes XML contents straight to it.
It is written in C#, but the core information coming out of it is the XML formatting used to create nodes and fill attributes for corresponding cell values and formatting.
Please consider I have not tried this myself, I found it while doing a search. Please feel free to ask if some C# bits are not clear. HTH

Trying to save a workbook that contains macros

I recently upgraded to Excel 2010. I was working on a spreadsheet and wrote some code and went to save it and I get this box that pops up. I'm not sure what to do.
From Office 2007 on, Excel has two different file types: XLSX and XLSM. The former is just data and formatting without macros or anything "dangerous." The latter allows macros and other programmatic functionality. The reason for the split is mainly security as each one has a distinct extension and icon to better inform the user on whether or not the file could potentially contain dangerous content.
In this instance, you need to click No, then in the Save As... options select "Excel Macro-Enabled Workbook." That will give you the full functionality of the original document.

Troubleshooting "call to undefined function" when adding Markdown to project

I'm trying to add some Markdown capabilities to my Symfony project (Symfony version 1.3.3).
To accomplish that, I had already included the Markdown library into lib/vendor directory. Also, I added the need configuration in the autoload.yml for the previous library.
However, I'm getting a fatal PHP error:
Call to undefined function Markdown()
How can I resolve this problem?
The symfony autoloader loads classes from php files named like <classname>.class.php. If you're using the markdown.php file from mitchelf.com, it does not follow the naming scheme, nor does it contain a class called Markdown, as a matter of fact: it has a function called Markdown.
Symfony isn't even trying to load it, for reasons I described above. You will have to include it manually. I suggest you have a look at http://www.symfony-project.org/plugins/sfEasyMarkdownPlugin.
I do NOT suggest installing a plugin for such a simple feature. It is not hard for you to figure it out if you have some real examples.
There is an open source project based on symfony named Bookeet. It has embedded MarkDowm feature. It uses markitup as the markdown editor. And it uses php markdown to convert markdown code to html code.
To save your time, go directly to changeset 29f0ba1807 of the Bookeet project(I am sorry that I can't post the hyperlink because SO doesn't permit new user to post more than one hyperlink). You could see clearly what should be done in order to add markdown feature to your website.

Strategy in exporting to Excel with formatting from ASP.NET?

So this is another exporting to Excel question.
I have a page that has a table with formatting by stylesheet.
When I export the page by setting the ContentType to application/excel and Content-Disposition to attachment, I can export the table to Excel (not CSV). However, it loses all formatting. I think it's because Excel does not load CSS and I guess that's reasonable.
So, in a scenario where I have to show the table on the web and also export to Excel, both with similar (even if not exact) formatting, what would be the best approach without using something like NPOI?
I am trying to minimize the work and keep the single template if possible. Is it necessary for me to create two separate templates: one with stylesheet, the other with embedded style in the table itself for Excel?
Having a single template with conditional formatting inside would be very messy.
Any ideas?
If you not yet solve the problem I'll recommend you to use Open XML SDK 2.0 for Microsoft Office (see http://www.microsoft.com/downloads/details.aspx?FamilyID=c6e744e5-36e9-45f5-8d8c-331df206e0d0&displaylang=en). With this way you will be able create an XLSX file without installing Excel on the server. XLSX file is compressed (like ZIP file) collection of xml files. Open XML SDK 2.0 helps you create and change XLSX file as pure xml files. At the first time if you look at Open XML SDK a lot of things look like strange, but it's only at the beginning. There are so named "Open XML SDK 2.0 Productivity Tool" (a part of Open XML SDK 2.0) which can generate a lot of useful code for you. Moreover you can create a nice Excel document which you can use as a prototype (template) of the document which you will create. So you can solve the problem of complex formating without writing of a lot of code.
Look at http://msdn.microsoft.com/en-us/library/cc850837(v=office.14).aspx for some examples and on http://openxmldeveloper.org/default.aspx. See also Creating Excel document with OpenXml sdk 2.0 as a start example. You can find also a lot of good stuffs on http://www.codeplex.com about Open XML SDK
there are several aproach
you could instantiate a excel object on your server using VSTO, and then write the document on memory and write to response the native file, but this aproach could be a litle expensive if you create a excel object per request, so you could try to do a singleton object that wraps the excel object instance
You can create a report (rdlc file) with a similar look to the grid. Then, you can have an action where you instantiate a LocalReport, pass the data you want to it and call its Render method. You then return the byte array returned by the Render method.

Resources