IntroductionMicrosoft Excel is a wonderful tool which allows you to capture and analyze all kind of data, but one of the great features of Excel, is its ability to do simple data entry, whether you are a programmer or not. What if you could click a button and have your Excel data displayed inside a grid in the browser? Then anyone could see your data, if they are on a Mac or PC, and they don't even need to own Excel to see it. This article will illustrate that moving Excel Documents into Silverlight is a snap if your Excel spreadsheet is saved in an XML file. Saving your spreadsheet in XMLTo save your Excel spreadsheet as XML, first open up your Excel spreadsheet and go to the file menu (the little round circle in the upper left hand corner with the logo in it). Click Save As and choose XML spreadsheet 2003 (*.xml). This is what you will see if you are using Office 2007. Choose the directory you want to save the spreadsheet and click the Save button. Your xml file will have an XML representation of your spreadsheet as you might expect, with nodes containing workbook, worksheet, rows, and cells. You can see that all the data is contained within the cell structure much like the programmable Excel COM interface you might use to extract data from Excel. Listing 1 - Excel Worksheet saved in XML<Worksheet ss:Name="Sheet1">
<Table ss:ExpandedColumnCount="4" ss:ExpandedRowCount="4" x:FullColumns="1"
x:FullRows="1" ss:DefaultRowHeight="15">
<Column ss:Width="74.25"/>
<Column ss:Width="84.75"/>
<Column ss:Index="4" ss:Width="130.5"/>
<Row ss:AutoFitHeight="0">
<Cell><Data ss:Type="String">Name</Data></Cell>
<Cell><Data ss:Type="String">Address</Data></Cell>
<Cell><Data ss:Type="String">State</Data></Cell>
<Cell><Data ss:Type="String">How did you hear about us</Data></Cell>
</Row>
<Row ss:AutoFitHeight="0">
<Cell><Data ss:Type="String">Mahesh Chand</Data></Cell>
<Cell><Data ss:Type="String">40W Maple Drive</Data></Cell>
<Cell><Data ss:Type="String">PA</Data></Cell>
<Cell><Data ss:Type="String">Web</Data></Cell>
</Row>
<Row ss:AutoFitHeight="0">
<Cell><Data ss:Type="String">Mike Gold</Data></Cell>
<Cell><Data ss:Type="String">100 Lamar Drive</Data></Cell>
<Cell><Data ss:Type="String">TX</Data></Cell>
<Cell><Data ss:Type="String">Google Search</Data></Cell>
</Row>Read more: C# Corner
<Table ss:ExpandedColumnCount="4" ss:ExpandedRowCount="4" x:FullColumns="1"
x:FullRows="1" ss:DefaultRowHeight="15">
<Column ss:Width="74.25"/>
<Column ss:Width="84.75"/>
<Column ss:Index="4" ss:Width="130.5"/>
<Row ss:AutoFitHeight="0">
<Cell><Data ss:Type="String">Name</Data></Cell>
<Cell><Data ss:Type="String">Address</Data></Cell>
<Cell><Data ss:Type="String">State</Data></Cell>
<Cell><Data ss:Type="String">How did you hear about us</Data></Cell>
</Row>
<Row ss:AutoFitHeight="0">
<Cell><Data ss:Type="String">Mahesh Chand</Data></Cell>
<Cell><Data ss:Type="String">40W Maple Drive</Data></Cell>
<Cell><Data ss:Type="String">PA</Data></Cell>
<Cell><Data ss:Type="String">Web</Data></Cell>
</Row>
<Row ss:AutoFitHeight="0">
<Cell><Data ss:Type="String">Mike Gold</Data></Cell>
<Cell><Data ss:Type="String">100 Lamar Drive</Data></Cell>
<Cell><Data ss:Type="String">TX</Data></Cell>
<Cell><Data ss:Type="String">Google Search</Data></Cell>
</Row>Read more: C# Corner
0 comments:
Post a Comment