C# - Office XML: Using XSLT to generate an excel document

October 20, 2010 by C#   Microsoft Office  

In my previous post I swiftly explained how to create an excel document in PHP using Office XML (OpenXML's older not so clever brother).

In this post we're going to do the same thing (Excel via Office XML) using C#, but instead of simply "translating" the PHP code, I am going to "introduce" another technology into the equation - a technology called XSLT (Extensible Stylesheet Language Transformations).

The basic idea is to define a XSLT file which will produce the following Office XML spreadsheet as output:

<?xml version="1.0" ?> 
<?mso-application progid="Excel.Sheet"?> 
<ss:Workbook xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet">
	<ss:Worksheet ss:Name="Sheet1">
		<ss:Table>
			<ss:Row>
				<ss:Cell>
					<ss:Data ss:Type="String">Firstname</ss:Data> 
				</ss:Cell>
				<ss:Cell>
					<ss:Data ss:Type="String">Lastname</ss:Data> 
				</ss:Cell>
			</ss:Row>
		</ss:Table>
	</ss:Worksheet>
</ss:Workbook>

Firstly we need to rewrite the preceding XML sheet into XSLT format/schema, which essentially becomes our template, which we'll populate using a DataSet, observe:

workbook.xslt
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
                xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" 
                version="1.0">
  <xsl:output encoding="utf-8" />
  <xsl:template match="NewDataSet">
    <xsl:text disable-output-escaping="yes">
    <![CDATA[<?mso-application progid="Excel.Sheet"?> ]]>    
    </xsl:text>
    <ss:Workbook>
      <ss:Worksheet ss:Name="Sheet1">
        <ss:Table>
          <xsl:apply-templates select="Table1"/>
        </ss:Table>
      </ss:Worksheet>
    </ss:Workbook>
  </xsl:template>
  <xsl:template match="Table1">
    <ss:Row>
      <ss:Cell>
        <ss:Data ss:Type="String">
          <xsl:value-of select="Firstname"/>
        </ss:Data>
      </ss:Cell>
      <ss:Cell>
        <ss:Data ss:Type="String">
          <xsl:value-of select="Lastname"/>
        </ss:Data>
      </ss:Cell>
    </ss:Row>
  </xsl:template>
</xsl:stylesheet>

(I am not going to explain all of the XML above - it pretty much contains the basics used in XSLT, you can read more about XSLT by clicking here.)

Notice the match & select attributes "NewDataSet", "Table1", "Firstname" and "Lastname" - these are values we're going to extract from the XML generated from our DataSet - the following XML will be generated via the WriteXml method used in the GetDocument method in this post.

<NewDataSet>
	<Table1>
		<Firstname>Jason</Firstname> 
		<Lastname>Smith</Lastname> 
	</Table1>
	<Table1>
		<Firstname>Wayne</Firstname> 
		<Lastname>Kleynhans</Lastname> 
	</Table1>
</NewDataSet>
(Note that NewDataSet & Table1 are default element names that will be rendered if we don't name our DataSet/DataTables etc)

XML generated by our DataSet??? Well... We will need to get a XML representation of our DataSet in order to bind it to the XSLT sheet.

In the following snippet we transform the XSLT file into an Office XML Spreadsheet:

using System.Data;
using System.IO;
using System.Xml.Xsl;
using System.Xml.XPath;

class Program
{	
	// Some fake Data 
    static DataSet GetData()
    {
        DataSet ds = new DataSet();
        DataTable dt = new DataTable();
        dt.Columns.AddRange(new DataColumn[] { 
                new DataColumn("Firstname"), 
                new DataColumn("Lastname") });
        dt.Rows.Add(new object[] { "Jason", "Smith" });
        dt.Rows.Add(new object[] { "Wayne", "Kleynhans" });
        ds.Tables.Add(dt);
        return ds;
    }

    static XPathDocument GetDocument(DataSet ds)
    {
        using (StringWriter sw = new StringWriter())
        {
            ds.WriteXml(sw);
            using (StringReader sr = new StringReader(sw.ToString()))
            {
                return new XPathDocument(sr);
            }
        }
    }

    static void Main(string[] args)
    {
        DataSet ds = GetData();
        XPathDocument input = GetDocument(ds);

        using (FileStream output = new FileStream(@"c:\xls.xml", FileMode.CreateNew))
        {
            XslCompiledTransform xslt = new XslCompiledTransform();
            xslt.Load("workbook.xslt");
            xslt.Transform(input, null, output);
        }
    }
}

The end result is a file containing the Office XML spreadsheet.


Leave a Comment


November 9, 2011 by Christoff Truter

Hi RK My guess is that you'll need multiple sheets? Member With HCCList Prescriptions LabResults Sooo your XSLT sheet will be pretty involved, it might be alot easier to go the OpenXml Route Have a look at http://www.cstruter.com/blog/291 And you might want to deserialize your XML to .net objects as well (you can use a tool like xsd.exe to generate .net classes from your XML schema) The following post will give you some clue about the xsd.exe tool http://cstruter.com/blog/256

November 9, 2011 by Christoff Truter

Hi Programmer This link should give you an idea http://www.cstruter.com/blog/291

November 9, 2011 by Programmer

Hi Christoff, I have got my mistake, I was searching for .xlsx file. Your code works fine. I have checked your code is working for .xls. However my project requirement is to produce output in .xlsx file format. Could you please provide any hints on how to get the .xlsx file format?

November 9, 2011 by RK

Hi Christoff, PFB the XML <Response> <ReqDate>11/8/2011</ReqDate> <Member> <MemberName>JANNIE CHATMAN</MemberName> <HumanaID>H42036247</HumanaID> <MemberDOB>01/30/1940</MemberDOB> <MemberGender>F</MemberGender> <PCP>PLAZA MEDICAL CENTER</PCP> <City>MIAMI</City> <State>FL</State> <Phone>3052554556</Phone> <PlanName>N2230001</PlanName> <Date>20050301</Date> </Member> <HEDISAnalytics/> <RiskAdj> <RiskScoreThisYear>4.524</RiskScoreThisYear> <RiskScoreLastYear>5.572</RiskScoreLastYear> <HCCList> <HCC> <HCCDecscription>RENAL FAILURE</HCCDecscription> <HCCCode>131</HCCCode> <HCCDateThisYr>January 1, 2011 thru December 31, 2011</HCCDateThisYr> <StatusThisYear>CMS ACCEPTED, NO SUSPECT STATUS</StatusThisYear> <HCCDateLastYr>January 1, 2011 thru December 31, 2011</HCCDateLastYr> <StatusLastYear>CMS ACCEPTED, NO SUSPECT STATUS</StatusLastYear> </HCC> <HCC> <HCCDecscription>BREAST, PROSTATE, COLORECTAL AND OTHER CANCERS AND TUMORS</HCCDecscription> <HCCCode>10</HCCCode> <HCCDateThisYr>January 1, 2011 thru December 31, 2011</HCCDateThisYr> <StatusThisYear>CMS ACCEPTED, NO SUSPECT STATUS</StatusThisYear> <HCCDateLastYr>January 1, 2011 thru December 31, 2011</HCCDateLastYr> <StatusLastYear>CMS ACCEPTED, NO SUSPECT STATUS</StatusLastYear> </HCC> </HCCList> </RiskAdj> <Prescriptions> <Prescription> <DateFilled>2009-11-18</DateFilled> <Drug_Name>FLUTICASONE PROPIONATE</Drug_Name> <Dosage>50.000 - MCG/ACT</Dosage> <Days_Supply>30</Days_Supply> <Alternate_Drug_Name>Fluticasone Propionate Nasal Susp 50 MCG/ACT</Alternate_Drug_Name> <PrescribingDr>Michael Cavanaugh</PrescribingDr> <RrefillIndicator>0</RrefillIndicator> <NumberOfRefill>0</NumberOfRefill> </Prescription> <Prescription> <DateFilled>2011-08-31</DateFilled> <Drug_Name>ROXICET</Drug_Name> <Dosage>0.000 - </Dosage> <Days_Supply>3</Days_Supply> <Alternate_Drug_Name>Oxycodone w/ Acetaminophen Tab 5-325 MG</Alternate_Drug_Name> <PrescribingDr>Silvio Vinardell</PrescribingDr> <RrefillIndicator>0</RrefillIndicator> <NumberOfRefill>0</NumberOfRefill> </Prescription> <Prescription> <DateFilled>2010-01-06</DateFilled> <Drug_Name>DIOVAN</Drug_Name> <Dosage>160.000 - MG</Dosage> <Days_Supply>30</Days_Supply> <Alternate_Drug_Name>Valsartan Tab 160 MG</Alternate_Drug_Name> <PrescribingDr>Carlos Vazquez</PrescribingDr> <RrefillIndicator>0</RrefillIndicator> <NumberOfRefill>0</NumberOfRefill> </Prescription> <Prescription> <DateFilled>2011-10-15</DateFilled> <Drug_Name>DIOVAN</Drug_Name> <Dosage>160.000 - MG</Dosage> <Days_Supply>30</Days_Supply> <Alternate_Drug_Name>Valsartan Tab 160 MG</Alternate_Drug_Name> <PrescribingDr>David M Trueba</PrescribingDr> <RrefillIndicator>0</RrefillIndicator> <NumberOfRefill>0</NumberOfRefill> </Prescription> <Prescription> <DateFilled>2010-01-06</DateFilled> <Drug_Name>AMOX TR-POTASSIUM CLAVULANATE</Drug_Name> <Dosage>0.000 - </Dosage> <Days_Supply>5</Days_Supply> <Alternate_Drug_Name>Amoxicillin & K Clavulanate Tab 500-125 MG</Alternate_Drug_Name> <PrescribingDr>Carlos Vazquez</PrescribingDr> <RrefillIndicator>0</RrefillIndicator> <NumberOfRefill>0</NumberOfRefill> </Prescription> <Prescription> <DateFilled>2010-04-30</DateFilled> <Drug_Name>GLYBURIDE</Drug_Name> <Dosage>5.000 - MG</Dosage> <Days_Supply>30</Days_Supply> <Alternate_Drug_Name>Glyburide Tab 5 MG</Alternate_Drug_Name> <PrescribingDr>Michael Cavanaugh</PrescribingDr> <RrefillIndicator>0</RrefillIndicator> <NumberOfRefill>0</NumberOfRefill> </Prescription> <Prescription> <DateFilled>2010-08-15</DateFilled> <Drug_Name>GLYBURIDE</Drug_Name> <Dosage>5.000 - MG</Dosage> <Days_Supply>30</Days_Supply> <Alternate_Drug_Name>Glyburide Tab 5 MG</Alternate_Drug_Name> <PrescribingDr>Michael Cavanaugh</PrescribingDr> <RrefillIndicator>2</RrefillIndicator> <NumberOfRefill>2</NumberOfRefill> </Prescription> <Prescription> <DateFilled>2011-03-02</DateFilled> <Drug_Name>GLYBURIDE</Drug_Name> <Dosage>5.000 - MG</Dosage> <Days_Supply>30</Days_Supply> <Alternate_Drug_Name>Glyburide Tab 5 MG</Alternate_Drug_Name> <PrescribingDr>Michael Cavanaugh</PrescribingDr> <RrefillIndicator>5</RrefillIndicator> <NumberOfRefill>5</NumberOfRefill> </Prescription> <Prescription> <DateFilled>2011-09-28</DateFilled> <Drug_Name>GLYBURIDE</Drug_Name> <Dosage>5.000 - MG</Dosage> <Days_Supply>30</Days_Supply> <Alternate_Drug_Name>Glyburide Tab 5 MG</Alternate_Drug_Name> <PrescribingDr>Michael Cavanaugh</PrescribingDr> <RrefillIndicator>5</RrefillIndicator> <NumberOfRefill>5</NumberOfRefill> </Prescription> <Prescription> <DateFilled>2010-01-06</DateFilled> <Drug_Name>ECOTRIN</Drug_Name> <Dosage>81.000 - MG</Dosage> <Days_Supply>30</Days_Supply> <Alternate_Drug_Name>Aspirin Tab Delayed Release 81 MG</Alternate_Drug_Name> <PrescribingDr>Carlos Vazquez</PrescribingDr> <RrefillIndicator>0</RrefillIndicator> <NumberOfRefill>0</NumberOfRefill> </Prescription> <Prescription> <DateFilled>2009-12-14</DateFilled> <Drug_Name>COLCHICINE</Drug_Name> <Dosage>0.600 - MG</Dosage> <Days_Supply>30</Days_Supply> <Alternate_Drug_Name>Colchicine Tab 0.6 MG</Alternate_Drug_Name> <PrescribingDr>Michael Cavanaugh</PrescribingDr> <RrefillIndicator>2</RrefillIndicator> <NumberOfRefill>2</NumberOfRefill> </Prescription> <Prescription> <DateFilled>2010-04-07</DateFilled> <Drug_Name>COLCHICINE</Drug_Name> <Dosage>0.600 - MG</Dosage> <Days_Supply>30</Days_Supply> <Alternate_Drug_Name>Colchicine Tab 0.6 MG</Alternate_Drug_Name> <PrescribingDr>Michael Cavanaugh</PrescribingDr> <RrefillIndicator>1</RrefillIndicator> <NumberOfRefill>1</NumberOfRefill> </Prescription> <Prescription> <DateFilled>2011-02-09</DateFilled> <Drug_Name>CICLOPIROX</Drug_Name> <Dosage>0.770 - %</Dosage> <Days_Supply>10</Days_Supply> <Alternate_Drug_Name>Ciclopirox Gel 0.77%</Alternate_Drug_Name> <PrescribingDr>Phyllis Skolnik</PrescribingDr> <RrefillIndicator>2</RrefillIndicator> <NumberOfRefill>2</NumberOfRefill> </Prescription> <Prescription> <DateFilled>2010-02-13</DateFilled> <Drug_Name>NOVOLIN 70-30</Drug_Name> <Dosage>0.000 - </Dosage> <Days_Supply>40</Days_Supply> <Alternate_Drug_Name>Insulin Isophane & Regular (Human) Inj 100 Unit/ML (70-30)</Alternate_Drug_Name> <PrescribingDr>Michael Cavanaugh</PrescribingDr> <RrefillIndicator>6</RrefillIndicator> <NumberOfRefill>6</NumberOfRefill> </Prescription> <Prescription> <DateFilled>2011-01-18</DateFilled> <Drug_Name>NOVOLIN 70-30</Drug_Name> <Dosage>0.000 - </Dosage> <Days_Supply>20</Days_Supply> <Alternate_Drug_Name>Insulin Isophane & Regular (Human) Inj 100 Unit/ML (70-30)</Alternate_Drug_Name> <PrescribingDr>Michael Cavanaugh</PrescribingDr> <RrefillIndicator>6</RrefillIndicator> <NumberOfRefill>6</NumberOfRefill> </Prescription> <Prescription> <DateFilled>2011-04-25</DateFilled> <Drug_Name>NOVOLIN 70-30</Drug_Name> <Dosage>0.000 - </Dosage> <Days_Supply>30</Days_Supply> <Alternate_Drug_Name>Insulin Isophane & Regular (Human) Inj 100 Unit/ML (70-30)</Alternate_Drug_Name> <PrescribingDr>Michael Cavanaugh</PrescribingDr> <RrefillIndicator>1</RrefillIndicator> <NumberOfRefill>1</NumberOfRefill> </Prescription> <Prescription> <DateFilled>2011-10-15</DateFilled> <Drug_Name>NOVOLIN 70-30</Drug_Name> <Dosage>0.000 - </Dosage> <Days_Supply>22</Days_Supply> <Alternate_Drug_Name>Insulin Isophane & Regular (Human) Inj 100 Unit/ML (70-30)</Alternate_Drug_Name> <PrescribingDr>David M Trueba</PrescribingDr> <RrefillIndicator>0</RrefillIndicator> <NumberOfRefill>0</NumberOfRefill> </Prescription> <Prescription> <DateFilled>2011-09-13</DateFilled> <Drug_Name>NOVOLIN 70-30</Drug_Name> <Dosage>0.000 - </Dosage> <Days_Supply>30</Days_Supply> <Alternate_Drug_Name>Insulin Isophane & Regular (Human) Inj 100 Unit/ML (70-30)</Alternate_Drug_Name> <PrescribingDr>Michael Cavanaugh</PrescribingDr> <RrefillIndicator>1</RrefillIndicator> <NumberOfRefill>1</NumberOfRefill> </Prescription> <Prescription> <DateFilled>2011-04-25</DateFilled> <Drug_Name>FUROSEMIDE</Drug_Name> <Dosage>40.000 - MG</Dosage> <Days_Supply>30</Days_Supply> <Alternate_Drug_Name>Furosemide Tab 40 MG</Alternate_Drug_Name> <PrescribingDr>Michael Cavanaugh</PrescribingDr> <RrefillIndicator>1</RrefillIndicator> <NumberOfRefill>1</NumberOfRefill> </Prescription> <Prescription> <DateFilled>2011-03-09</DateFilled> <Drug_Name>KLOR-CON 10</Drug_Name> <Dosage>10.000 - MEQ</Dosage> <Days_Supply>30</Days_Supply> <Alternate_Drug_Name>Potassium Chloride Tab CR 10 mEq</Alternate_Drug_Name> <PrescribingDr>Michael Cavanaugh</PrescribingDr> <RrefillIndicator>0</RrefillIndicator> <NumberOfRefill>0</NumberOfRefill> </Prescription> <Prescription> <DateFilled>2009-12-14</DateFilled> <Drug_Name>ALLOPURINOL</Drug_Name> <Dosage>100.000 - MG</Dosage> <Days_Supply>30</Days_Supply> <Alternate_Drug_Name>Allopurinol Tab 100 MG</Alternate_Drug_Name> <PrescribingDr>Michael Cavanaugh</PrescribingDr> <RrefillIndicator>2</RrefillIndicator> <NumberOfRefill>2</NumberOfRefill> </Prescription> <Prescription> <DateFilled>2010-01-20</DateFilled> <Drug_Name>ALLOPURINOL</Drug_Name> <Dosage>100.000 - MG</Dosage> <Days_Supply>30</Days_Supply> <Alternate_Drug_Name>Allopurinol Tab 100 MG</Alternate_Drug_Name> <PrescribingDr>Michael Cavanaugh</PrescribingDr> <RrefillIndicator>0</RrefillIndicator> <NumberOfRefill>0</NumberOfRefill> </Prescription> <Prescription> <DateFilled>2010-02-25</DateFilled> <Drug_Name>ALLOPURINOL</Drug_Name> <Dosage>100.000 - MG</Dosage> <Days_Supply>30</Days_Supply> <Alternate_Drug_Name>Allopurinol Tab 100 MG</Alternate_Drug_Name> <PrescribingDr>Olivia Graves</PrescribingDr> <RrefillIndicator>0</RrefillIndicator> <NumberOfRefill>0</NumberOfRefill> </Prescription> <Prescription> <DateFilled>2010-08-23</DateFilled> <Drug_Name>ALLOPURINOL</Drug_Name> <Dosage>300.000 - MG</Dosage> <Days_Supply>30</Days_Supply> <Alternate_Drug_Name>Allopurinol Tab 300 MG</Alternate_Drug_Name> <PrescribingDr>Olivia Graves</PrescribingDr> <RrefillIndicator>5</RrefillIndicator> <NumberOfRefill>5</NumberOfRefill> </Prescription> <Prescription> <DateFilled>2010-11-01</DateFilled> <Drug_Name>ALLOPURINOL</Drug_Name> <Dosage>300.000 - MG</Dosage> <Days_Supply>30</Days_Supply> <Alternate_Drug_Name>Allopurinol Tab 300 MG</Alternate_Drug_Name> <PrescribingDr>Michael Cavanaugh</PrescribingDr> <RrefillIndicator>1</RrefillIndicator> <NumberOfRefill>1</NumberOfRefill> </Prescription> <Prescription> <DateFilled>2011-03-16</DateFilled> <Drug_Name>ALLOPURINOL</Drug_Name> <Dosage>300.000 - MG</Dosage> <Days_Supply>30</Days_Supply> <Alternate_Drug_Name>Allopurinol Tab 300 MG</Alternate_Drug_Name> <PrescribingDr>Michael Cavanaugh</PrescribingDr> <RrefillIndicator>3</RrefillIndicator> <NumberOfRefill>3</NumberOfRefill> </Prescription> <Prescription> <DateFilled>2011-07-07</DateFilled> <Drug_Name>ALLOPURINOL</Drug_Name> <Dosage>300.000 - MG</Dosage> <Days_Supply>30</Days_Supply> <Alternate_Drug_Name>Allopurinol Tab 300 MG</Alternate_Drug_Name> <PrescribingDr>Michael Cavanaugh</PrescribingDr> <RrefillIndicator>3</RrefillIndicator> <NumberOfRefill>3</NumberOfRefill> </Prescription> <Prescription> <DateFilled>2011-11-01</DateFilled> <Drug_Name>ALLOPURINOL</Drug_Name> <Dosage>300.000 - MG</Dosage> <Days_Supply>30</Days_Supply> <Alternate_Drug_Name>Allopurinol Tab 300 MG</Alternate_Drug_Name> <PrescribingDr>Michael Cavanaugh</PrescribingDr> <RrefillIndicator>2</RrefillIndicator> <NumberOfRefill>2</NumberOfRefill> </Prescription> <Prescription> <DateFilled>2011-08-31</DateFilled> <Drug_Name>CYCLOBENZAPRINE HCL</Drug_Name> <Dosage>5.000 - MG</Dosage> <Days_Supply>3</Days_Supply> <Alternate_Drug_Name>Cyclobenzaprine HCl Tab 5 MG</Alternate_Drug_Name> <PrescribingDr>Silvio Vinardell</PrescribingDr> <RrefillIndicator>0</RrefillIndicator> <NumberOfRefill>0</NumberOfRefill> </Prescription> <Prescription> <DateFilled>2011-10-15</DateFilled> <Drug_Name>HYDROCHLOROTHIAZIDE</Drug_Name> <Dosage>12.500 - MG</Dosage> <Days_Supply>30</Days_Supply> <Alternate_Drug_Name>Hydrochlorothiazide Cap 12.5 MG</Alternate_Drug_Name> <PrescribingDr>David M Trueba</PrescribingDr> <RrefillIndicator>0</RrefillIndicator> <NumberOfRefill>0</NumberOfRefill> </Prescription> <Prescription> <DateFilled>2011-03-23</DateFilled> <Drug_Name>METOLAZONE</Drug_Name> <Dosage>2.500 - MG</Dosage> <Days_Supply>30</Days_Supply> <Alternate_Drug_Name>Metolazone Tab 2.5 MG</Alternate_Drug_Name> <PrescribingDr>Michael Cavanaugh</PrescribingDr> <RrefillIndicator>0</RrefillIndicator> <NumberOfRefill>0</NumberOfRefill> </Prescription> <Prescription> <DateFilled>2011-10-15</DateFilled> <Drug_Name>HYDROCODONE-ACETAMINOPHEN</Drug_Name> <Dosage>0.000 - </Dosage> <Days_Supply>5</Days_Supply> <Alternate_Drug_Name>Hydrocodone-Acetaminophen Tab 5-500 MG</Alternate_Drug_Name> <PrescribingDr>David M Trueba</PrescribingDr> <RrefillIndicator>0</RrefillIndicator> <NumberOfRefill>0</NumberOfRefill> </Prescription> <Prescription> <DateFilled>2010-01-06</DateFilled> <Drug_Name>OXYCODONE-ACETAMINOPHEN</Drug_Name> <Dosage>0.000 - </Dosage> <Days_Supply>10</Days_Supply> <Alternate_Drug_Name>Oxycodone w/ Acetaminophen Tab 5-325 MG</Alternate_Drug_Name> <PrescribingDr>Carlos Vazquez</PrescribingDr> <RrefillIndicator>0</RrefillIndicator> <NumberOfRefill>0</NumberOfRefill> </Prescription> <Prescription> <DateFilled>2011-05-16</DateFilled> <Drug_Name>CICLOPIROX</Drug_Name> <Dosage>0.770 - %</Dosage> <Days_Supply>30</Days_Supply> <Alternate_Drug_Name>Ciclopirox Gel 0.77%</Alternate_Drug_Name> <PrescribingDr>Phyllis Skolnik</PrescribingDr> <RrefillIndicator>0</RrefillIndicator> <NumberOfRefill>0</NumberOfRefill> </Prescription> <Prescription> <DateFilled>2011-03-04</DateFilled> <Drug_Name>CICLOPIROX</Drug_Name> <Dosage>0.770 - %</Dosage> <Days_Supply>30</Days_Supply> <Alternate_Drug_Name>Ciclopirox Gel 0.77%</Alternate_Drug_Name> <PrescribingDr>Phyllis Skolnik</PrescribingDr> <RrefillIndicator>3</RrefillIndicator> <NumberOfRefill>3</NumberOfRefill> </Prescription> <Prescription> <DateFilled>2010-04-30</DateFilled> <Drug_Name>INSULIN SYRINGE</Drug_Name> <Dosage>0.000 - </Dosage> <Days_Supply>30</Days_Supply> <Alternate_Drug_Name>Insulin Syringe/Needle U-100 1/2 ML 30 x 1/2"</Alternate_Drug_Name> <PrescribingDr>Ricardo Martinez</PrescribingDr> <RrefillIndicator>2</RrefillIndicator> <NumberOfRefill>2</NumberOfRefill> </Prescription> <Prescription> <DateFilled>2011-09-13</DateFilled> <Drug_Name>INSULIN SYRINGE</Drug_Name> <Dosage>0.000 - </Dosage> <Days_Supply>30</Days_Supply> <Alternate_Drug_Name>Insulin Syringe/Needle U-100 1/2 ML 30 x 1/2"</Alternate_Drug_Name> <PrescribingDr>Ricardo Martinez</PrescribingDr> <RrefillIndicator>1</RrefillIndicator> <NumberOfRefill>1</NumberOfRefill> </Prescription> <Prescription> <DateFilled>2011-10-15</DateFilled> <Drug_Name>INSULIN SYRINGE</Drug_Name> <Dosage>0.000 - </Dosage> <Days_Supply>30</Days_Supply> <Alternate_Drug_Name>Insulin Syringe/Needle U-100 1/2 ML 30 x 1/2"</Alternate_Drug_Name> <PrescribingDr>David M Trueba</PrescribingDr> <RrefillIndicator>0</RrefillIndicator> <NumberOfRefill>0</NumberOfRefill> </Prescription> <Prescription> <DateFilled>2011-09-28</DateFilled> <Drug_Name>KETOCONAZOLE</Drug_Name> <Dosage>2.000 - %</Dosage> <Days_Supply>30</Days_Supply> <Alternate_Drug_Name>Ketoconazole Cream 2%</Alternate_Drug_Name> <PrescribingDr>Phyllis Skolnik</PrescribingDr> <RrefillIndicator>3</RrefillIndicator> <NumberOfRefill>3</NumberOfRefill> </Prescription> <Prescription> <DateFilled>2011-05-16</DateFilled> <Drug_Name>KETOCONAZOLE</Drug_Name> <Dosage>2.000 - %</Dosage> <Days_Supply>30</Days_Supply> <Alternate_Drug_Name>Ketoconazole Cream 2%</Alternate_Drug_Name> <PrescribingDr>Phyllis Skolnik</PrescribingDr> <RrefillIndicator>0</RrefillIndicator> <NumberOfRefill>0</NumberOfRefill> </Prescription> <Prescription> <DateFilled>2011-04-25</DateFilled> <Drug_Name>POTASSIUM CHLORIDE</Drug_Name> <Dosage>20.000 - MEQ</Dosage> <Days_Supply>30</Days_Supply> <Alternate_Drug_Name>Potassium Chloride Microencapsulated Crys CR Tab 20 mEq</Alternate_Drug_Name> <PrescribingDr>Michael Cavanaugh</PrescribingDr> <RrefillIndicator>0</RrefillIndicator> <NumberOfRefill>0</NumberOfRefill> </Prescription> <Prescription> <DateFilled>2011-10-15</DateFilled> <Drug_Name>SULFAMETHOXAZOLE-TRIMETHOPRIM</Drug_Name> <Dosage>0.000 - </Dosage> <Days_Supply>14</Days_Supply> <Alternate_Drug_Name>Sulfamethoxazole-Trimethoprim Tab 800-160 MG</Alternate_Drug_Name> <PrescribingDr>David M Trueba</PrescribingDr> <RrefillIndicator>0</RrefillIndicator> <NumberOfRefill>0</NumberOfRefill> </Prescription> </Prescriptions> <LabResults> <LabResult> <LabEventDate>06/08/2011</LabEventDate> <LOINCCode>5787-7</LOINCCode> <ActualResults>0-10E</ActualResults> <LOINC_DESCRIPTION>Epithelial cells</LOINC_DESCRIPTION> <LabValue /> <NormalRange>0-0</NormalRange> </LabResult> <LabResult> <LabEventDate>06/08/2011</LabEventDate> <LOINCCode>5794-3</LOINCCode> <ActualResults>N</ActualResults> <LOINC_DESCRIPTION>Hemoglobin</LOINC_DESCRIPTION> <LabValue /> <NormalRange>0-0</NormalRange> </LabResult> <LabResult> <LabEventDate>06/08/2011</LabEventDate> <LOINCCode>5799-2</LOINCCode> <ActualResults>N</ActualResults> <LOINC_DESCRIPTION>Leukocyte esterase</LOINC_DESCRIPTION> <LabValue /> <NormalRange>0-0</NormalRange> </LabResult> <LabResult> <LabEventDate>06/08/2011</LabEventDate> <LOINCCode>5802-4</LOINCCode> <ActualResults>N</ActualResults> <LOINC_DESCRIPTION>Nitrite</LOINC_DESCRIPTION> <LabValue /> <NormalRange>0-0</NormalRange> </LabResult> <LabResult> <LabEventDate>06/08/2011</LabEventDate> <LOINCCode>713-8</LOINCCode> <ActualResults>6</ActualResults> <LOINC_DESCRIPTION>Eosinophils/100 leukocytes</LOINC_DESCRIPTION> <LabValue /> <NormalRange>0-7</NormalRange> </LabResult> <LabResult> <LabEventDate>06/08/2011</LabEventDate> <LOINCCode>718-7</LOINCCode> <ActualResults>11.9</ActualResults> <LOINC_DESCRIPTION>Hemoglobin</LOINC_DESCRIPTION> <LabValue /> <NormalRange>11.5-15</NormalRange> </LabResult> <LabResult> <LabEventDate>06/08/2011</LabEventDate> <LOINCCode>731-0</LOINCCode> <ActualResults>2.0</ActualResults> <LOINC_DESCRIPTION>Lymphocytes</LOINC_DESCRIPTION> <LabValue /> <NormalRange>0.7-4.5</NormalRange> </LabResult> <LabResult> <LabEventDate>06/08/2011</LabEventDate> <LOINCCode>736-9</LOINCCode> <ActualResults>31</ActualResults> <LOINC_DESCRIPTION>Lymphocytes/100 leukocytes</LOINC_DESCRIPTION> <LabValue /> <NormalRange>14-46</NormalRange> </LabResult> <LabResult> <LabEventDate>06/08/2011</LabEventDate> <LOINCCode>13457-7</LOINCCode> <ActualResults>112</ActualResults> <LOINC_DESCRIPTION>Cholesterol.in LDL</LOINC_DESCRIPTION> <LabValue>H</LabValue> <NormalRange>0-99</NormalRange> </LabResult> <LabResult> <LabEventDate>06/08/2011</LabEventDate> <LOINCCode>742-7</LOINCCode> <ActualResults>0.3</ActualResults> <LOINC_DESCRIPTION>Monocytes</LOINC_DESCRIPTION> <LabValue /> <NormalRange>0.1-1</NormalRange> </LabResult> <LabResult> <LabEventDate>06/08/2011</LabEventDate> <LOINCCode>13458-5</LOINCCode> <ActualResults>21</ActualResults> <LOINC_DESCRIPTION>Cholesterol.in VLDL</LOINC_DESCRIPTION> <LabValue /> <NormalRange>5-40</NormalRange> </LabResult> <LabResult> <LabEventDate>06/08/2011</LabEventDate> <LOINCCode>751-8</LOINCCode> <ActualResults>3.7</ActualResults> <LOINC_DESCRIPTION>Neutrophils</LOINC_DESCRIPTION> <LabValue /> <NormalRange>1.8-7.8</NormalRange> </LabResult> <LabResult> <LabEventDate>06/08/2011</LabEventDate> <LOINCCode>13945-1</LOINCCode> <ActualResults>NOSEE</ActualResults> <LOINC_DESCRIPTION>Erythrocytes</LOINC_DESCRIPTION> <LabValue /> <NormalRange>0-0</NormalRange> </LabResult> <LabResult> <LabEventDate>06/08/2011</LabEventDate> <LOINCCode>770-8</LOINCCode> <ActualResults>57</ActualResults> <LOINC_DESCRIPTION>Neutrophils/100 leukocytes</LOINC_DESCRIPTION> <LabValue /> <NormalRange>40-74</NormalRange> </LabResult> <LabResult> <LabEventDate>06/08/2011</LabEventDate> <LOINCCode>14959-1</LOINCCode> <ActualResults>867.8</ActualResults> <LOINC_DESCRIPTION>Albumin/Creatinine</LOINC_DESCRIPTION> <LabValue>H</LabValue> <NormalRange>0-30</NormalRange> </LabResult> <LabResult> <LabEventDate>06/08/2011</LabEventDate> <LOINCCode>14957-5</LOINCCode> <ActualResults>560.6</ActualResults> <LOINC_DESCRIPTION>Albumin</LOINC_DESCRIPTION> <LabValue>H</LabValue> <NormalRange>0-17</NormalRange> </LabResult> <LabResult> <LabEventDate>06/08/2011</LabEventDate> <LOINCCode>2965-2</LOINCCode> <ActualResults>1.017</ActualResults> <LOINC_DESCRIPTION>Specific gravity</LOINC_DESCRIPTION> <LabValue /> <NormalRange>1.005-1.03</NormalRange> </LabResult> <LabResult> <LabEventDate>06/08/2011</LabEventDate> <LOINCCode>777-3</LOINCCode> <ActualResults>197</ActualResults> <LOINC_DESCRIPTION>Platelets</LOINC_DESCRIPTION> <LabValue /> <NormalRange>140-415</NormalRange> </LabResult> <LabResult> <LabEventDate>06/08/2011</LabEventDate> <LOINCCode>1742-6</LOINCCode> <ActualResults>22</ActualResults> <LOINC_DESCRIPTION>Alanine aminotransferase</LOINC_DESCRIPTION> <LabValue /> <NormalRange>0-40</NormalRange> </LabResult> <LabResult> <LabEventDate>06/08/2011</LabEventDate> <LOINCCode>785-6</LOINCCode> <ActualResults>26.7</ActualResults> <LOINC_DESCRIPTION>Erythrocyte mean corpuscular hemoglobin</LOINC_DESCRIPTION> <LabValue>L</LabValue> <NormalRange>27-34</NormalRange> </LabResult> <LabResult> <LabEventDate>06/08/2011</LabEventDate> <LOINCCode>786-4</LOINCCode> <ActualResults>32.2</ActualResults> <LOINC_DESCRIPTION>Erythrocyte mean corpuscular hemoglobin concentration</LOINC_DESCRIPTION> <LabValue /> <NormalRange>32-36</NormalRange> </LabResult> <LabResult> <LabEventDate>06/08/2011</LabEventDate> <LOINCCode>1751-7</LOINCCode> <ActualResults>3.8</ActualResults> <LOINC_DESCRIPTION>Albumin</LOINC_DESCRIPTION> <LabValue /> <NormalRange>3.5-4.8</NormalRange> </LabResult> <LabResult> <LabEventDate>06/08/2011</LabEventDate> <LOINCCode>20405-7</LOINCCode> <ActualResults>0.0</ActualResults> <LOINC_DESCRIPTION>Urobilinogen</LOINC_DESCRIPTION> <LabValue /> <NormalRange>0-1.9</NormalRange> </LabResult> <LabResult> <LabEventDate>06/08/2011</LabEventDate> <LOINCCode>3094-0</LOINCCode> <ActualResults>33</ActualResults> <LOINC_DESCRIPTION>Urea nitrogen</LOINC_DESCRIPTION> <LabValue>H</LabValue> <NormalRange>8-27</NormalRange> </LabResult> <LabResult> <LabEventDate>06/08/2011</LabEventDate> <LOINCCode>20454-5</LOINCCode> <ActualResults>UR2</ActualResults> <LOINC_DESCRIPTION>Protein</LOINC_DESCRIPTION> <LabValue>A</LabValue> <NormalRange>0-0</NormalRange> </LabResult> <LabResult> <LabEventDate>06/08/2011</LabEventDate> <LOINCCode>787-2</LOINCCode> <ActualResults>83</ActualResults> <LOINC_DESCRIPTION>Erythrocyte mean corpuscular volume</LOINC_DESCRIPTION> <LabValue /> <NormalRange>80-98</NormalRange> </LabResult> <LabResult> <LabEventDate>06/08/2011</LabEventDate> <LOINCCode>3097-3</LOINCCode> <ActualResults>29</ActualResults> <LOINC_DESCRIPTION>Urea nitrogen/Creatinine</LOINC_DESCRIPTION> <LabValue>H</LabValue> <NormalRange>11-26</NormalRange> </LabResult> <LabResult> <LabEventDate>06/08/2011</LabEventDate> <LOINCCode>1759-0</LOINCCode> <ActualResults>1.5</ActualResults> <LOINC_DESCRIPTION>Albumin/Globulin</LOINC_DESCRIPTION> <LabValue /> <NormalRange>1.1-2.5</NormalRange> </LabResult> <LabResult> <LabEventDate>06/08/2011</LabEventDate> <LOINCCode>2075-0</LOINCCode> <ActualResults>104</ActualResults> <LOINC_DESCRIPTION>Chloride</LOINC_DESCRIPTION> <LabValue /> <NormalRange>97-108</NormalRange> </LabResult> <LabResult> <LabEventDate>06/08/2011</LabEventDate> <LOINCCode>788-0</LOINCCode> <ActualResults>16.2</ActualResults> <LOINC_DESCRIPTION>Erythrocyte distribution width</LOINC_DESCRIPTION> <LabValue>H</LabValue> <NormalRange>11.7-15</NormalRange> </LabResult> <LabResult> <LabEventDate>06/08/2011</LabEventDate> <LOINCCode>17861-6</LOINCCode> <ActualResults>9.4</ActualResults> <LOINC_DESCRIPTION>Calcium</LOINC_DESCRIPTION> <LabValue /> <NormalRange>8.6-10.2</NormalRange> </LabResult> <LabResult> <LabEventDate>06/08/2011</LabEventDate> <LOINCCode>789-8</LOINCCode> <ActualResults>4.46</ActualResults> <LOINC_DESCRIPTION>Erythrocytes</LOINC_DESCRIPTION> <LabValue /> <NormalRange>3.8-5.1</NormalRange> </LabResult> <LabResult> <LabEventDate>06/08/2011</LabEventDate> <LOINCCode>38518-7</LOINCCode> <ActualResults>0</ActualResults> <LOINC_DESCRIPTION>Granulocytes.immature/100 leukocytes</LOINC_DESCRIPTION> <LabValue /> <NormalRange>0-2</NormalRange> </LabResult> <LabResult> <LabEventDate>06/08/2011</LabEventDate> <LOINCCode>2085-9</LOINCCode> <ActualResults>64</ActualResults> <LOINC_DESCRIPTION>Cholesterol.in HDL</LOINC_DESCRIPTION> <LabValue /> <NormalRange>0-0</NormalRange> </LabResult> <LabResult> <LabEventDate>06/08/2011</LabEventDate> <LOINCCode>2093-3</LOINCCode> <ActualResults>197</ActualResults> <LOINC_DESCRIPTION>Cholesterol</LOINC_DESCRIPTION> <LabValue /> <NormalRange>100-199</NormalRange> </LabResult> <LabResult> <LabEventDate>06/08/2011</LabEventDate> <LOINCCode>8247-9</LOINCCode> <ActualResults>PRES</ActualResults> <LOINC_DESCRIPTION>Mucus</LOINC_DESCRIPTION> <LabValue /> <NormalRange>0-0</NormalRange> </LabResult> <LabResult> <LabEventDate>06/08/2011</LabEventDate> <LOINCCode>4537-7</LOINCCode> <ActualResults>17</ActualResults> <LOINC_DESCRIPTION>Erythrocyte sedimentation rate</LOINC_DESCRIPTION> <LabValue /> <NormalRange>0-56</NormalRange> </LabResult> <LabResult> <LabEventDate>06/08/2011</LabEventDate> <LOINCCode>1920-8</LOINCCode> <ActualResults>17</ActualResults> <LOINC_DESCRIPTION>Aspartate aminotransferase</LOINC_DESCRIPTION> <LabValue /> <NormalRange>0-40</NormalRange> </LabResult> <LabResult> <LabEventDate>06/08/2011</LabEventDate> <LOINCCode>4544-3</LOINCCode> <ActualResults>37.0</ActualResults> <LOINC_DESCRIPTION>Hematocrit</LOINC_DESCRIPTION> <LabValue /> <NormalRange>34-44</NormalRange> </LabResult> <LabResult> <LabEventDate>06/08/2011</LabEventDate> <LOINCCode>4548-4</LOINCCode> <ActualResults>8.8</ActualResults> <LOINC_DESCRIPTION>Hemoglobin A1c/Hemoglobin.total</LOINC_DESCRIPTION> <LabValue>H</LabValue> <NormalRange>4.8-5.6</NormalRange> </LabResult> <LabResult> <LabEventDate>06/08/2011</LabEventDate> <LOINCCode>1975-2</LOINCCode> <ActualResults>0.3</ActualResults> <LOINC_DESCRIPTION>Bilirubin</LOINC_DESCRIPTION> <LabValue /> <NormalRange>0-1.2</NormalRange> </LabResult> <LabResult> <LabEventDate>06/08/2011</LabEventDate> <LOINCCode>2160-0</LOINCCode> <ActualResults>1.12</ActualResults> <LOINC_DESCRIPTION>Creatinine</LOINC_DESCRIPTION> <LabValue>H</LabValue> <NormalRange>0.57-1</NormalRange> </LabResult> <LabResult> <LabEventDate>06/08/2011</LabEventDate> <LOINCCode>5803-2</LOINCCode> <ActualResults>6.0</ActualResults> <LOINC_DESCRIPTION>pH</LOINC_DESCRIPTION> <LabValue /> <NormalRange>5-7.5</NormalRange> </LabResult> <LabResult> <LabEventDate>06/08/2011</LabEventDate> <LOINCCode>2161-8</LOINCCode> <ActualResults>64.6</ActualResults> <LOINC_DESCRIPTION>Creatinine</LOINC_DESCRIPTION> <LabValue /> <NormalRange>15-278</NormalRange> </LabResult> <LabResult> <LabEventDate>06/08/2011</LabEventDate> <LOINCCode>10834-0</LOINCCode> <ActualResults>2.5</ActualResults> <LOINC_DESCRIPTION>Globulin</LOINC_DESCRIPTION> <LabValue /> <NormalRange>1.5-4.5</NormalRange> </LabResult> <LabResult> <LabEventDate>06/08/2011</LabEventDate> <LOINCCode>5821-4</LOINCCode> <ActualResults>0-5W</ActualResults> <LOINC_DESCRIPTION>Leukocytes</LOINC_DESCRIPTION> <LabValue /> <NormalRange>0-0</NormalRange> </LabResult> <LabResult> <LabEventDate>06/08/2011</LabEventDate> <LOINCCode>5905-5</LOINCCode> <ActualResults>5</ActualResults> <LOINC_DESCRIPTION>Monocytes/100 leukocytes</LOINC_DESCRIPTION> <LabValue /> <NormalRange>4-13</NormalRange> </LabResult> <LabResult> <LabEventDate>06/08/2011</LabEventDate> <LOINCCode>2028-9</LOINCCode> <ActualResults>25</ActualResults> <LOINC_DESCRIPTION>Carbon dioxide</LOINC_DESCRIPTION> <LabValue /> <NormalRange>20-32</NormalRange> </LabResult> <LabResult> <LabEventDate>06/08/2011</LabEventDate> <LOINCCode>2349-9</LOINCCode> <ActualResults>N</ActualResults> <LOINC_DESCRIPTION>Glucose</LOINC_DESCRIPTION> <LabValue /> <NormalRange>0-0</NormalRange> </LabResult> <LabResult> <LabEventDate>06/08/2011</LabEventDate> <LOINCCode>2345-7</LOINCCode> <ActualResults>130</ActualResults> <LOINC_DESCRIPTION>Glucose</LOINC_DESCRIPTION> <LabValue>H</LabValue> <NormalRange>65-99</NormalRange> </LabResult> <LabResult> <LabEventDate>06/08/2011</LabEventDate> <LOINCCode>6690-2</LOINCCode> <ActualResults>6.5</ActualResults> <LOINC_DESCRIPTION>Leukocytes</LOINC_DESCRIPTION> <LabValue /> <NormalRange>4-10.5</NormalRange> </LabResult> <LabResult> <LabEventDate>06/08/2011</LabEventDate> <LOINCCode>24365-9</LOINCCode> <ActualResults>MICRO</ActualResults> <LOINC_DESCRIPTION>Urinalysis microscopic panel</LOINC_DESCRIPTION> <LabValue /> <NormalRange>0-0</NormalRange> </LabResult> <LabResult> <LabEventDate>06/08/2011</LabEventDate> <LOINCCode>6768-6</LOINCCode> <ActualResults>126</ActualResults> <LOINC_DESCRIPTION>Alkaline phosphatase</LOINC_DESCRIPTION> <LabValue /> <NormalRange>25-165</NormalRange> </LabResult> <LabResult> <LabEventDate>06/08/2011</LabEventDate> <LOINCCode>2514-8</LOINCCode> <ActualResults>N</ActualResults> <LOINC_DESCRIPTION>Ketones</LOINC_DESCRIPTION> <LabValue /> <NormalRange>0-0</NormalRange> </LabResult> <LabResult> <LabEventDate>06/08/2011</LabEventDate> <LOINCCode>2571-8</LOINCCode> <ActualResults>103</ActualResults> <LOINC_DESCRIPTION>Triglyceride</LOINC_DESCRIPTION> <LabValue /> <NormalRange>0-149</NormalRange> </LabResult> <LabResult> <LabEventDate>06/08/2011</LabEventDate> <LOINCCode>704-7</LOINCCode> <ActualResults>0.1</ActualResults> <LOINC_DESCRIPTION>Basophils</LOINC_DESCRIPTION> <LabValue /> <NormalRange>0-0.2</NormalRange> </LabResult> <LabResult> <LabEventDate>06/08/2011</LabEventDate> <LOINCCode>2823-3</LOINCCode> <ActualResults>3.9</ActualResults> <LOINC_DESCRIPTION>Potassium</LOINC_DESCRIPTION> <LabValue /> <NormalRange>3.5-5.2</NormalRange> </LabResult> <LabResult> <LabEventDate>06/08/2011</LabEventDate> <LOINCCode>706-2</LOINCCode> <ActualResults>1</ActualResults> <LOINC_DESCRIPTION>Basophils/100 leukocytes</LOINC_DESCRIPTION> <LabValue /> <NormalRange>0-3</NormalRange> </LabResult> <LabResult> <LabEventDate>06/08/2011</LabEventDate> <LOINCCode>711-2</LOINCCode> <ActualResults>0.4</ActualResults> <LOINC_DESCRIPTION>Eosinophils</LOINC_DESCRIPTION> <LabValue /> <NormalRange>0-0.4</NormalRange> </LabResult> <LabResult> <LabEventDate>06/08/2011</LabEventDate> <LOINCCode>2885-2</LOINCCode> <ActualResults>6.3</ActualResults> <LOINC_DESCRIPTION>Protein</LOINC_DESCRIPTION> <LabValue /> <NormalRange>6-8.5</NormalRange> </LabResult> <LabResult> <LabEventDate>06/08/2011</LabEventDate> <LOINCCode>2951-2</LOINCCode> <ActualResults>143</ActualResults> <LOINC_DESCRIPTION>Sodium</LOINC_DESCRIPTION> <LabValue /> <NormalRange>135-145</NormalRange> </LabResult> <LabResult> <LabEventDate>06/08/2011</LabEventDate> <LOINCCode>48642-3</LOINCCode> <ActualResults>50</ActualResults> <LOINC_DESCRIPTION>Glomerular filtration rate/1.73 sq M.predicted.non black</LOINC_DESCRIPTION> <LabValue>L</LabValue> <NormalRange>0-0</NormalRange> </LabResult> <LabResult> <LabEventDate>06/08/2011</LabEventDate> <LOINCCode>48643-1</LOINCCode> <ActualResults>57</ActualResults> <LOINC_DESCRIPTION>Glomerular filtration rate/1.73 sq M.predicted.black</LOINC_DESCRIPTION> <LabValue>L</LabValue> <NormalRange>0-0</NormalRange> </LabResult> <LabResult> <LabEventDate>06/08/2011</LabEventDate> <LOINCCode>51584-1</LOINCCode> <ActualResults>0.0</ActualResults> <LOINC_DESCRIPTION>Granulocytes.immature</LOINC_DESCRIPTION> <LabValue /> <NormalRange>0-0.1</NormalRange> </LabResult> <LabResult> <LabEventDate>06/08/2011</LabEventDate> <LOINCCode>5767-9</LOINCCode> <ActualResults>CL</ActualResults> <LOINC_DESCRIPTION>Appearance</LOINC_DESCRIPTION> <LabValue /> <NormalRange>0-0</NormalRange> </LabResult> <LabResult> <LabEventDate>06/08/2011</LabEventDate> <LOINCCode>5769-5</LOINCCode> <ActualResults>URFEWB</ActualResults> <LOINC_DESCRIPTION>Bacteria</LOINC_DESCRIPTION> <LabValue /> <NormalRange>0-0</NormalRange> </LabResult> <LabResult> <LabEventDate>06/08/2011</LabEventDate> <LOINCCode>5770-3</LOINCCode> <ActualResults>N</ActualResults> <LOINC_DESCRIPTION>Bilirubin</LOINC_DESCRIPTION> <LabValue /> <NormalRange>0-0</NormalRange> </LabResult> <LabResult> <LabEventDate>06/08/2011</LabEventDate> <LOINCCode>5778-6</LOINCCode> <ActualResults>YL</ActualResults> <LOINC_DESCRIPTION>Color</LOINC_DESCRIPTION> <LabValue /> <NormalRange>0-0</NormalRange> </LabResult> <LabResult> <LabEventDate>04/19/2011</LabEventDate> <LOINCCode>3024-7</LOINCCode> <ActualResults>1.14</ActualResults> <LOINC_DESCRIPTION>Thyroxine.free</LOINC_DESCRIPTION> <LabValue /> <NormalRange>0.82-1.77</NormalRange> </LabResult> <LabResult> <LabEventDate>04/19/2011</LabEventDate> <LOINCCode>4548-4</LOINCCode> <ActualResults>8.6</ActualResults> <LOINC_DESCRIPTION>Hemoglobin A1c/Hemoglobin.total</LOINC_DESCRIPTION> <LabValue>H</LabValue> <NormalRange>4.8-5.6</NormalRange> </LabResult> <LabResult> <LabEventDate>04/19/2011</LabEventDate> <LOINCCode>2028-9</LOINCCode> <ActualResults>26</ActualResults> <LOINC_DESCRIPTION>Carbon dioxide</LOINC_DESCRIPTION> <LabValue /> <NormalRange>20-32</NormalRange> </LabResult> <LabResult> <LabEventDate>04/19/2011</LabEventDate> <LOINCCode>785-6</LOINCCode> <ActualResults>26.9</ActualResults> <LOINC_DESCRIPTION>Erythrocyte mean corpuscular hemoglobin</LOINC_DESCRIPTION> <LabValue>L</LabValue> <NormalRange>27-34</NormalRange> </LabResult> <LabResult> <LabEventDate>04/19/2011</LabEventDate> <LOINCCode>704-7</LOINCCode> <ActualResults>0.0</ActualResults> <LOINC_DESCRIPTION>Basophils</LOINC_DESCRIPTION> <LabValue /> <NormalRange>0-0.2</NormalRange> </LabResult> <LabResult> <LabEventDate>04/19/2011</LabEventDate> <LOINCCode>736-9</LOINCCode> <ActualResults>27</ActualResults> <LOINC_DESCRIPTION>Lymphocytes/100 leukocytes</LOINC_DESCRIPTION> <LabValue /> <NormalRange>14-46</NormalRange> </LabResult> <LabResult> <LabEventDate>04/19/2011</LabEventDate> <LOINCCode>788-0</LOINCCode> <ActualResults>16.3</ActualResults> <LOINC_DESCRIPTION>Erythrocyte distribution width</LOINC_DESCRIPTION> <LabValue>H</LabValue> <NormalRange>11.7-15</NormalRange> </LabResult> <LabResult> <LabEventDate>04/19/2011</LabEventDate> <LOINCCode>2345-7</LOINCCode> <ActualResults>122</ActualResults> <LOINC_DESCRIPTION>Glucose</LOINC_DESCRIPTION> <LabValue>H</LabValue> <NormalRange>65-99</NormalRange> </LabResult> <LabResult> <LabEventDate>04/19/2011</LabEventDate> <LOINCCode>2085-9</LOINCCode> <ActualResults>64</ActualResults> <LOINC_DESCRIPTION>Cholesterol.in HDL</LOINC_DESCRIPTION> <LabValue /> <NormalRange>0-0</NormalRange> </LabResult> <LabResult> <LabEventDate>04/19/2011</LabEventDate> <LOINCCode>2160-0</LOINCCode> <ActualResults>1.07</ActualResults> <LOINC_DESCRIPTION>Creatinine</LOINC_DESCRIPTION> <LabValue>H</LabValue> <NormalRange>0.57-1</NormalRange> </LabResult> <LabResult> <LabEventDate>04/19/2011</LabEventDate> <LOINCCode>706-2</LOINCCode> <ActualResults>1</ActualResults> <LOINC_DESCRIPTION>Basophils/100 leukocytes</LOINC_DESCRIPTION> <LabValue /> <NormalRange>0-3</NormalRange> </LabResult> <LabResult> <LabEventDate>04/19/2011</LabEventDate> <LOINCCode>742-7</LOINCCode> <ActualResults>0.3</ActualResults> <LOINC_DESCRIPTION>Monocytes</LOINC_DESCRIPTION> <LabValue /> <NormalRange>0.1-1</NormalRange> </LabResult> <LabResult> <LabEventDate>04/19/2011</LabEventDate> <LOINCCode>789-8</LOINCCode> <ActualResults>4.91</ActualResults> <LOINC_DESCRIPTION>Erythrocytes</LOINC_DESCRIPTION> <LabValue /> <NormalRange>3.8-5.1</NormalRange> </LabResult> <LabResult> <LabEventDate>04/19/2011</LabEventDate> <LOINCCode>3051-0</LOINCCode> <ActualResults>2.8</ActualResults> <LOINC_DESCRIPTION>Triiodothyronine.free</LOINC_DESCRIPTION> <LabValue /> <NormalRange>2-4.4</NormalRange> </LabResult> <LabResult> <LabEventDate>04/19/2011</LabEventDate> <LOINCCode>711-2</LOINCCode> <ActualResults>0.4</ActualResults> <LOINC_DESCRIPTION>Eosinophils</LOINC_DESCRIPTION> <LabValue /> <NormalRange>0-0.4</NormalRange> </LabResult> <LabResult> <LabEventDate>04/19/2011</LabEventDate> <LOINCCode>6690-2</LOINCCode> <ActualResults>6.5</ActualResults> <LOINC_DESCRIPTION>Leukocytes</LOINC_DESCRIPTION> <LabValue /> <NormalRange>4-10.5</NormalRange> </LabResult> <LabResult> <LabEventDate>04/19/2011</LabEventDate> <LOINCCode>718-7</LOINCCode> <ActualResults>13.2</ActualResults> <LOINC_DESCRIPTION>Hemoglobin</LOINC_DESCRIPTION> <LabValue /> <NormalRange>11.5-15</NormalRange> </LabResult> <LabResult> <LabEventDate>04/19/2011</LabEventDate> <LOINCCode>751-8</LOINCCode> <ActualResults>4.0</ActualResults> <LOINC_DESCRIPTION>Neutrophils</LOINC_DESCRIPTION> <LabValue /> <NormalRange>1.8-7.8</NormalRange> </LabResult> <LabResult> <LabEventDate>04/19/2011</LabEventDate> <LOINCCode>731-0</LOINCCode> <ActualResults>1.8</ActualResults> <LOINC_DESCRIPTION>Lymphocytes</LOINC_DESCRIPTION> <LabValue /> <NormalRange>0.7-4.5</NormalRange> </LabResult> <LabResult> <LabEventDate>04/19/2011</LabEventDate> <LOINCCode>6768-6</LOINCCode> <ActualResults>136</ActualResults> <LOINC_DESCRIPTION>Alkaline phosphatase</LOINC_DESCRIPTION> <LabValue /> <NormalRange>25-165</NormalRange> </LabResult> <LabResult> <LabEventDate>04/19/2011</LabEventDate> <LOINCCode>48643-1</LOINCCode> <ActualResults>60</ActualResults> <LOINC_DESCRIPTION>Glomerular filtration rate/1.73 sq M.predicted.black</LOINC_DESCRIPTION> <LabValue /> <NormalRange>0-0</NormalRange> </LabResult> <LabResult> <LabEventDate>04/19/2011</LabEventDate> <LOINCCode>786-4</LOINCCode> <ActualResults>32.3</ActualResults> <LOINC_DESCRIPTION>Erythrocyte mean corpuscular hemoglobin concentration</LOINC_DESCRIPTION> <LabValue /> <NormalRange>32-36</NormalRange> </LabResult> <LabResult> <LabEventDate>04/19/2011</LabEventDate> <LOINCCode>17861-6</LOINCCode> <ActualResults>9.8</ActualResults> <LOINC_DESCRIPTION>Calcium</LOINC_DESCRIPTION> <LabValue /> <NormalRange>8.6-10.2</NormalRange> </LabResult> <LabResult> <LabEventDate>04/19/2011</LabEventDate> <LOINCCode>38518-7</LOINCCode> <ActualResults>0</ActualResults> <LOINC_DESCRIPTION>Granulocytes.immature/100 leukocytes</LOINC_DESCRIPTION> <LabValue /> <NormalRange>0-1</NormalRange> </LabResult> <LabResult> <LabEventDate>04/19/2011</LabEventDate> <LOINCCode>2823-3</LOINCCode> <ActualResults>4.1</ActualResults> <LOINC_DESCRIPTION>Potassium</LOINC_DESCRIPTION> <LabValue /> <NormalRange>3.5-5.2</NormalRange> </LabResult> <LabResult> <LabEventDate>04/19/2011</LabEventDate> <LOINCCode>11579-0</LOINCCode> <ActualResults>3.100</ActualResults> <LOINC_DESCRIPTION>Thyrotropin</LOINC_DESCRIPTION> <LabValue /> <NormalRange>0.45-4.5</NormalRange> </LabResult> <LabResult> <LabEventDate>04/19/2011</LabEventDate> <LOINCCode>1975-2</LOINCCode> <ActualResults>0.2</ActualResults> <LOINC_DESCRIPTION>Bilirubin</LOINC_DESCRIPTION> <LabValue /> <NormalRange>0-1.2</NormalRange> </LabResult> <LabResult> <LabEventDate>04/19/2011</LabEventDate> <LOINCCode>51584-1</LOINCCode> <ActualResults>0.0</ActualResults> <LOINC_DESCRIPTION>Granulocytes.immature</LOINC_DESCRIPTION> <LabValue /> <NormalRange>0-0.1</NormalRange> </LabResult> <LabResult> <LabEventDate>04/19/2011</LabEventDate> <LOINCCode>13457-7</LOINCCode> <ActualResults>117</ActualResults> <LOINC_DESCRIPTION>Cholesterol.in LDL</LOINC_DESCRIPTION> <LabValue>H</LabValue> <NormalRange>0-99</NormalRange> </LabResult> <LabResult> <LabEventDate>04/19/2011</LabEventDate> <LOINCCode>3094-0</LOINCCode> <ActualResults>23</ActualResults> <LOINC_DESCRIPTION>Urea nitrogen</LOINC_DESCRIPTION> <LabValue /> <NormalRange>8-27</NormalRange> </LabResult> <LabResult> <LabEventDate>04/19/2011</LabEventDate> <LOINCCode>1751-7</LOINCCode> <ActualResults>3.6</ActualResults> <LOINC_DESCRIPTION>Albumin</LOINC_DESCRIPTION> <LabValue /> <NormalRange>3.5-4.8</NormalRange> </LabResult> <LabResult> <LabEventDate>04/19/2011</LabEventDate> <LOINCCode>10834-0</LOINCCode> <ActualResults>2.7</ActualResults> <LOINC_DESCRIPTION>Globulin</LOINC_DESCRIPTION> <LabValue /> <NormalRange>1.5-4.5</NormalRange> </LabResult> <LabResult> <LabEventDate>04/19/2011</LabEventDate> <LOINCCode>48642-3</LOINCCode> <ActualResults>52</ActualResults> <LOINC_DESCRIPTION>Glomerular filtration rate/1.73 sq M.predicted.non black</LOINC_DESCRIPTION> <LabValue>L</LabValue> <NormalRange>0-0</NormalRange> </LabResult> <LabResult> <LabEventDate>04/19/2011</LabEventDate> <LOINCCode>1920-8</LOINCCode> <ActualResults>17</ActualResults> <LOINC_DESCRIPTION>Aspartate aminotransferase</LOINC_DESCRIPTION> <LabValue /> <NormalRange>0-40</NormalRange> </LabResult> <LabResult> <LabEventDate>04/19/2011</LabEventDate> <LOINCCode>2571-8</LOINCCode> <ActualResults>84</ActualResults> <LOINC_DESCRIPTION>Triglyceride</LOINC_DESCRIPTION> <LabValue /> <NormalRange>0-149</NormalRange> </LabResult> <LabResult> <LabEventDate>04/19/2011</LabEventDate> <LOINCCode>2885-2</LOINCCode> <ActualResults>6.3</ActualResults> <LOINC_DESCRIPTION>Protein</LOINC_DESCRIPTION> <LabValue /> <NormalRange>6-8.5</NormalRange> </LabResult> <LabResult> <LabEventDate>04/19/2011</LabEventDate> <LOINCCode>5905-5</LOINCCode> <ActualResults>5</ActualResults> <LOINC_DESCRIPTION>Monocytes/100 leukocytes</LOINC_DESCRIPTION> <LabValue /> <NormalRange>4-13</NormalRange> </LabResult> <LabResult> <LabEventDate>04/19/2011</LabEventDate> <LOINCCode>11054-4</LOINCCode> <ActualResults>1.8</ActualResults> <LOINC_DESCRIPTION>Cholesterol.in LDL/Cholesterol.in HDL</LOINC_DESCRIPTION> <LabValue /> <NormalRange>0-3.2</NormalRange> </LabResult> <LabResult> <LabEventDate>04/19/2011</LabEventDate> <LOINCCode>2075-0</LOINCCode> <ActualResults>103</ActualResults> <LOINC_DESCRIPTION>Chloride</LOINC_DESCRIPTION> <LabValue /> <NormalRange>97-108</NormalRange> </LabResult> <LabResult> <LabEventDate>04/19/2011</LabEventDate> <LOINCCode>713-8</LOINCCode> <ActualResults>5</ActualResults> <LOINC_DESCRIPTION>Eosinophils/100 leukocytes</LOINC_DESCRIPTION> <LabValue /> <NormalRange>0-7</NormalRange> </LabResult> <LabResult> <LabEventDate>04/19/2011</LabEventDate> <LOINCCode>770-8</LOINCCode> <ActualResults>62</ActualResults> <LOINC_DESCRIPTION>Neutrophils/100 leukocytes</LOINC_DESCRIPTION> <LabValue /> <NormalRange>40-74</NormalRange> </LabResult> <LabResult> <LabEventDate>04/19/2011</LabEventDate> <LOINCCode>787-2</LOINCCode> <ActualResults>83</ActualResults> <LOINC_DESCRIPTION>Erythrocyte mean corpuscular volume</LOINC_DESCRIPTION> <LabValue /> <NormalRange>80-98</NormalRange> </LabResult> <LabResult> <LabEventDate>04/19/2011</LabEventDate> <LOINCCode>777-3</LOINCCode> <ActualResults>206</ActualResults> <LOINC_DESCRIPTION>Platelets</LOINC_DESCRIPTION> <LabValue /> <NormalRange>140-415</NormalRange> </LabResult> <LabResult> <LabEventDate>04/19/2011</LabEventDate> <LOINCCode>1989-3</LOINCCode> <ActualResults>29.5</ActualResults> <LOINC_DESCRIPTION>Calcidiol</LOINC_DESCRIPTION> <LabValue>L</LabValue> <NormalRange>32-100</NormalRange> </LabResult> <LabResult> <LabEventDate>04/19/2011</LabEventDate> <LOINCCode>2093-3</LOINCCode> <ActualResults>198</ActualResults> <LOINC_DESCRIPTION>Cholesterol</LOINC_DESCRIPTION> <LabValue /> <NormalRange>100-199</NormalRange> </LabResult> <LabResult> <LabEventDate>04/19/2011</LabEventDate> <LOINCCode>4544-3</LOINCCode> <ActualResults>40.9</ActualResults> <LOINC_DESCRIPTION>Hematocrit</LOINC_DESCRIPTION> <LabValue /> <NormalRange>34-44</NormalRange> </LabResult> <LabResult> <LabEventDate>04/19/2011</LabEventDate> <LOINCCode>3097-3</LOINCCode> <ActualResults>21</ActualResults> <LOINC_DESCRIPTION>Urea nitrogen/Creatinine</LOINC_DESCRIPTION> <LabValue /> <NormalRange>11-26</NormalRange> </LabResult> <LabResult> <LabEventDate>04/19/2011</LabEventDate> <LOINCCode>1742-6</LOINCCode> <ActualResults>22</ActualResults> <LOINC_DESCRIPTION>Alanine aminotransferase</LOINC_DESCRIPTION> <LabValue /> <NormalRange>0-40</NormalRange> </LabResult> <LabResult> <LabEventDate>04/19/2011</LabEventDate> <LOINCCode>2951-2</LOINCCode> <ActualResults>143</ActualResults> <LOINC_DESCRIPTION>Sodium</LOINC_DESCRIPTION> <LabValue /> <NormalRange>135-145</NormalRange> </LabResult> <LabResult> <LabEventDate>04/19/2011</LabEventDate> <LOINCCode>1759-0</LOINCCode> <ActualResults>1.3</ActualResults> <LOINC_DESCRIPTION>Albumin/Globulin</LOINC_DESCRIPTION> <LabValue /> <NormalRange>1.1-2.5</NormalRange> </LabResult> <LabResult> <LabEventDate>04/19/2011</LabEventDate> <LOINCCode>13458-5</LOINCCode> <ActualResults>17</ActualResults> <LOINC_DESCRIPTION>Cholesterol.in VLDL</LOINC_DESCRIPTION> <LabValue /> <NormalRange>5-40</NormalRange> </LabResult> <LabResult> <LabEventDate>01/12/2011</LabEventDate> <LOINCCode>5821-4</LOINCCode> <ActualResults>0-5W</ActualResults> <LOINC_DESCRIPTION>Leukocytes</LOINC_DESCRIPTION> <LabValue /> <NormalRange>0-0</NormalRange> </LabResult> <LabResult> <LabEventDate>01/12/2011</LabEventDate> <LOINCCode>1920-8</LOINCCode> <ActualResults>20</ActualResults> <LOINC_DESCRIPTION>Aspartate aminotransferase</LOINC_DESCRIPTION> <LabValue /> <NormalRange>0-40</NormalRange> </LabResult> <LabResult> <LabEventDate>01/12/2011</LabEventDate> <LOINCCode>2160-0</LOINCCode> <ActualResults>0.83</ActualResults> <LOINC_DESCRIPTION>Creatinine</LOINC_DESCRIPTION> <LabValue /> <NormalRange>0.57-1</NormalRange> </LabResult> <LabResult> <LabEventDate>01/12/2011</LabEventDate> <LOINCCode>5905-5</LOINCCode> <ActualResults>6</ActualResults> <LOINC_DESCRIPTION>Monocytes/100 leukocytes</LOINC_DESCRIPTION> <LabValue /> <NormalRange>4-13</NormalRange> </LabResult>

November 8, 2011 by Christoff Truter

Hi RK Can you give me a sample of the XML you need to transform? Cause thats the whole "trick" to matching it up with the XSLT...

November 8, 2011 by Christoff Truter

Only thing I did differently is used the Server.MapPath method protected void Page_Load(object sender, EventArgs e) { DataSet NewDataSet = GetData(); XPathDocument input = GetDocument(NewDataSet); string strXMLFilePath = string.Empty; string filePath = Server.MapPath("~/Output"); strXMLFilePath = filePath + @"\" + "xls.xml"; FileInfo objFileInfo; if (!strXMLFilePath.Equals(string.Empty)) { objFileInfo = new FileInfo(strXMLFilePath); if (objFileInfo.Exists) { objFileInfo.Delete(); } using (FileStream output = new FileStream(strXMLFilePath, FileMode.CreateNew)) { XslCompiledTransform xslt = new XslCompiledTransform(); xslt.Load(Server.MapPath("~/Templates/workbook.xslt")); xslt.Transform(input, null, output); } } }

Works November 8, 2011 by Christoff Truter

Hi Programmer I tried your code inside a little test web app and everything works perfectly, whats happening/not happening on your side?

November 8, 2011 by RK

Hi Christoff, I hav given a task in which I have to convert XML (coming out of Webservice) to spreadsheet (formatted). Could you please help on this. Thanks RK

November 8, 2011 by Programmer

Hi Christoff, I have modified your code little bit like below in aspx page. However I dont get any output. Could you please verify what I am doing wrong? protected void Page_Load(object sender, EventArgs e) { DataSet NewDataSet = GetData(); XPathDocument input = GetDocument(NewDataSet); string strXMLFilePath = string.Empty; string filePath = @"U:\Sample Projects\WEbApplications\ExportXMLtoExcel"; strXMLFilePath = filePath + @"\" + "xls.xml"; FileInfo objFileInfo; if (!strXMLFilePath.Equals(string.Empty)) { objFileInfo = new FileInfo(strXMLFilePath); if (objFileInfo.Exists) { objFileInfo.Delete(); } using (FileStream output = new FileStream(strXMLFilePath, FileMode.CreateNew)) { XslCompiledTransform xslt = new XslCompiledTransform(); xslt.Load(@"U:\Sample Projects\WEbApplications\ExportXMLtoExcel\workbook.xslt"); xslt.Transform(input, null, output); } } } static DataSet GetData() { DataSet NewDataSet = new DataSet(); DataTable Table1 = new DataTable(); Table1.Columns.AddRange(new DataColumn[] { new DataColumn("Firstname"), new DataColumn("Lastname") }); Table1.Rows.Add(new object[] { "Jason", "Smith" }); Table1.Rows.Add(new object[] { "Wayne", "Kleynhans" }); NewDataSet.Tables.Add(Table1); return NewDataSet; } static XPathDocument GetDocument(DataSet ds) { using (StringWriter sw = new StringWriter()) { ds.WriteXml(sw); using (StringReader sr = new StringReader(sw.ToString())) { return new XPathDocument(sr); } } }

November 4, 2011 by Christoff Truter

The complete sources are provided in this post? (And works, tested it again) What problems are you experiencing? You do realise that this code will generate an office xml document (which excel treats like an exel document) - extension xml? And not an actual xls/xlsx file?