Posted at: 5:47 PM on 24 February 2012 by Muhimbi
Earlier this week I posted about the fact that the Muhimbi PDF Converter Services and the PDF Converter for SharePoint now support output to formats other than PDF. This opens up a whole new world of possibilities such as converting between DOC and DOCX, XLS and XLSX, but more importantly it also supports converting between completely different document types such as Excel to MS-Word and HTML to Excel.
This post describes another new conversion type that should be of particular interest to our InfoPath customers as it is now possible to convert InfoPath forms to MS-Word, Excel and HTML.
Conversion to these new formats generally works very well, but there are some limitations due to the nature of these non-PDF based destination formats. Specifically:
- Attachments: When converting an InfoPath form to PDF we also convert all attachments and merge them to the main PDF. This is possible because you can represent almost any file format in PDF and merge them together. Unfortunately this is not possible when converting to HTML, MS-Word or Excel.
- View Selection: We provide a number of ways to specify which view or views to convert. When converting to PDF it is possible to specify multiple views, which our converter then merges together into a single document. When converting to HTML, MS-Word or Excel it is only possible to convert a single view as these file formats don’t make merging easy. As a workaround you can create a ‘conversion specific view’ and combine the content of multiple views in it.
Print Views are also ignored when converting to HTML, Word or Excel. Instead you will need to use Muhimbi’s View Selection facilities if you wish to convert any view other than the default View.
- Formatting: PDF is a super flexible format that allows any content to be placed pretty much anywhere on the page. MS-Word, Excel and HTML are not necessarily this flexible. For example, Excel uses a ‘cell based approach’ to display content. If your InfoPath form is not specifically designed for export to Excel, e.g. it uses nested tables or different column widths across a page, then you may need to optimise your InfoPath form for conversion, or create a ‘conversion specific view’.
Detail about how to convert to these new document types (as well as to PDF) can be found here.
InfoPath to HTML (MHT)
When converting InfoPath to HTML the resulting file is a self contained MHT file that most modern browsers can display. All information including images, HTML and style sheets are included in this single file.
As you can see in the image above, InfoPath data can be represented in HTML really well so it is usually not needed to make any changes.
InfoPath to MS-Word
Depending on how an InfoPath form has been designed, some work may be required to make things look better when converting to MS-Word. This is mainly due to the fact that MS-Word does not like dimensions that are expressed in percentages, while it is common in InfoPath to create a table grid and populate that grid with controls that take up 100% of the available cell space.
Looking at the ‘before optimisation’ conversion results in the image displayed above, there are 2 things that are not quite right:
- Dimension of text fields: The dimensions of most text fields are not quite right. This can easily be changed by opening the form in InfoPath Designer and changing the width of the various fields from ‘100%’ to the actual dimensions in cm or inches.
- Missing ‘year’ in date picker fields: Due the way the Date Picker is structured internally, modifying its width does not translate properly when displayed in MS-Word. To solve this change the date picker field to a regular text field either by creating a conversion specific view, or using a display rule.
The InfoPath to MS-Word facility can generate output in doc, docx, rtf, txt, html and odt formats.
InfoPath to Excel
InfoPath to Excel conversion for existing forms, which are not optimised for conversion to Excel, are probably the trickiest ones to get right. If you don’t care about the ‘look and feel’ of the Excel sheet then no change is required, but if the Excel forms need to ‘look good’ then you may need to rethink the way the form is designed.
Looking at the ‘before optimisation’ in the image above things don’t look too bad, but clearly it is not the same as the original. The main issues are as follows:
- Column Widths: As Excel uses a cell / grid based approach it is not possible to mix different column widths. The information in the form’s header requires different column width and spans than the columns used in the repeating table further down the page. By changing the horizontally oriented fields in the header to individual rows we no longer have this problem.
- Number formats: Depending on a cell’s content Excel sometimes tries to be ‘clever’. Most of the time this works great, but in this case a field with value ‘007’ is changed into a ‘7’. This could be fixed by changing the content of the InfoPath field into a formula and concatenating an apostrophe in front of it.
The InfoPath to Excel facility can generate output in xls, xlsx, csv and ods format.
In conclusion these new file formats work very well, especially if you are willing and able to make some tweaks. If you have any questions then either contact us or leave a comment below. We’d love to hear from you.