Thursday, February 25, 2016

How To: Fix Libre Office rendering problems on Windows

Today I needed to run an import that takes a pipe delimited csv but had been supplied with a Microsoft Excel file. Although Excel does allow for saving a spreadsheet in csv format it only supports comma separated which is of no use when many of the fields contain commas.

My colleague mentioned that Libre Office allows the user to chose the delimiter when exporting to a csv format so I decided to quickly install the current version (5.1) on the Windows box I use. On opening Calc I found the user interface completely screwed up, to the point that the application was unusable.

It turns out that the OpenGL rendering was the problem. Most likely down to the Quadro card in workstation not being able to support all the features Libre Office requires. It's possible to disable the use of OpenGL rendering through the GUI if you're able to get to it.


This can also be done by manually editing the registrymodifications.xcu file:
C:\Users\USERNAME\AppData\Roaming\LibreOffice\4\user\registrymodifications.xcu

Wednesday, January 27, 2016

How To: Filter an XML file using Powershell

Once again I've been using Powershell to work around a problem. A few thousand users have been serialised into an XML file that needs to be imported into an external system. The problem is that there are many users that need to be removed from this file and the system that generated the file in the first place isn't able to filter them out before doing the export, don't ask.

Fortunately Powershell makes this laborious task fairly straight forward. Using just a few lines of code, I've loaded in the export file along with a file of users that should be removed; then filter through the user objects in the XML and write the results out to a new file.

$usernames = Get-Content excludedUsers.txt
[xml]$xmlFile = Get-Content ".\users-export.xml"
$xmlFile.Application.Users.User | where-object {$usernames -notcontains $_.username} | % {$_.ParentNode.RemoveChild($_)}
$xmlFile.OuterXml | Out-File .\users-export-filtered.xml