Export VCF to Excel in C#

August 23, 2010

I recently needed to rescue contact data stored in a .vcf file (vCard) and export it into Excel.

As I did not want to spend much time on this work, I searched and found this C# solution on Code Project which reads VCF 2.1 files.

After a couple of modifications, the program was able to parse VCF 3.0 files, display the contents of the file in a multi-line text control, and copy the contents to the clipboard.

In Excel, the clipboard data can be pasted and the result saved as .xls or .xlsx file.

While the solution now works for my purposes (i.e. reading a VCF file and extracting contacts, phone numbers and address, email addresses, and websites), the code does not parse the full contents of a VCF file, and does not write a VCF file.

The original author was aware of some shortcomings of his solution, and so am I.

If I wrote a parser/writer from scratch, my solution would retrieve the data into dictionaries (1 per contact), and implement accessor properties to retrieve and store the requested data.

Nevertheless, if you want a simply data retrieval tool to copy existing data into an Excel sheet, the solution is good enough.

As it is derived work, the source code (C#, Visual Studio 2008) is licensed under the Code Project Open License, and can be downloaded here.


IIS issues with UrlRewriter.Net

August 19, 2010

Trying to build an ASP.Net application using UrlRewriter.Net for some of the pages, as sketched by this blog entry of ScottGu.

The rewriting generally works based on these rules:

<rewriter>
  <rewrite url="^~/text/(.+)$" to="~/text.aspx?title=${encode($1)}" />
  <rewrite url="^~/text/$" to="~/default.aspx" />
  <rewrite url="^~/text$" to="~/default.aspx" />
  ....
</rewriter>

but there are some issues, which are probably caused by IIS (IIS 7 on Windows 7 in this case) rather than the rewriting module.

The configuration above redirects any request to the /text/ directory to the test.aspx Web Page.

First lesson learned: if you expect “funny” characters in the URL parameter (i.e. everything that needs to get URL-encoded), use the encode transformation.

Second, ASP.Net somehow loses track of what the “real” current URL directory is, so the “~/” (application root path) may not evaluate as expected. Use ResolveUrl() in pages that are affected by a rewrite module.

Two mysteries remain, though:

  • a final dot in the URL causes a 404
  • a sequence of two dots in the URL causes a 400

If you follow the MS links on a related Stack Overflow question, you will find that they are aware of similar problems for about 2 years, with the issues still unresolved.

The best strategy seems to be to avoid generating these kind of URLs in the first place.


Windows 7 and DirectX APIs for .Net

August 18, 2010

For those who want to access Windows 7 features or DirectX from .Net, MSDN provides its Windows® API Code Pack for Microsoft® .NET Framework (3.5 SP1). Additional downloads may be necessary as sketched in the article.

For other APIs, see my previous posts.


Preview failed: UnableToStartGraph

August 13, 2010

I recently installed MediaPortal (1.1.0.0, Windows 7, Terratec Cinergy S2 HD PCI) and noticed two problems:

  • A channel scan did not recognize any channels (unlike TerraTec Home Cinema)
  • After importing a channel file and trying to preview a channel raised the error message “Preview failed: UnableToStartGraph”

The scanning problem was fixed by opening the TV Server Configuration, navigating to TV Servers, (computer name), (card), selecting the DvbS card type, “Edit”, and selecting DVBS as preferred network provider (it had been set to Generic before).

This allowed me to scan channels using DiSEqC = None.

The preview problem was fixed by selecting CyberLink decoders under Codecs and Renderer where available, and selecting Enhanced Video Renderer (EVR) in the Video Renderer tab.


oraddlscript 0.17

August 3, 2010

oraddlscript is a command-line utilty which generates CREATE scripts of database objects in an Oracle database using  the DBMS_METADATA.GET_DDL function.

The most recent update includes a separate executable using the DataDirect ADO.Net Data Provider to connect to an Oracle database (named oraddlscriptdd).

Command-line parameters and functionality are the same as in the original version.

The latest version of oraddlscript is available for download.


Follow

Get every new post delivered to your Inbox.