This project is read-only.

Brief Code Discussion

Sep 9, 2007 at 11:54 PM
Edited Sep 10, 2007 at 12:08 AM

Code of Interest

IIS Analyzer supports NSCA, IIS and W3CExtended log formats and each log file is read using the LogClasses.NSCALogConverter, LogClasses.IISLogConverter, and LogClasses.W3CEExtendedLogConverter extension classes.

Building an Open XML file from code is demonstrated in the Load Method of the LogClasses.LogConverter abstract class.

Log Converter Abstract Class

As each log file is processed, a LogConverter instance is created the Load method is called. The Load method uses the System.IO.Packaging library to build the document package. The benefit here is that we dont need Excel to create the Excel log files. (Some interop references from an early demo have since been removed).

Load Method

Each Excel package part must be defined using its standard Uniform Resource Locator and content type. Each part must be related to the main workbook part using using a PackageRelationship. This allows Excel to recognize the files within the Open XML zip package.

An Open XML Excel package contains the following XML documents.
  • Workbook
  • Shared Strings
  • Styles
  • Worksheet(s)

Within the LogClasses.LogConverter class, the workbook, shared strings and styles documents are built up using the standard System.XML XmlDocument. A log worksheet is then added which contains the data. This is built using the CreateWorksheetXML methods in the extension classes.


This method maps the column values of each line in the log file to an array of output values for excel row. Then WriteRow is then called from the LogConverter class to add a row element to the worksheet package part.

Other Notes

The LogClasses.StatisticsReader reads the Excel packages and calculates statistics for reporting.
The LogClasses.StatisticsWriter writes the report to Excel, but uses standard Interop cell by cell access.