473,586 Members | 2,566 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to read multiple worksheet from a single excel file

56 New Member
hello
Can any one tell me how to read multiple worksheets from a single excel file.I have stored that excel in xml file.so i want to read that xml that has multiple worksheet.And i want to store that multiple worksheet data in different table.How can i do it.Below is my xml file.


<?xml version="1.0"?>
<Workbook xmlns="urn:sche mas-microsoft-com:office:spre adsheet"
xmlns:o="urn:sc hemas-microsoft-com:office:offi ce"
xmlns:x="urn:sc hemas-microsoft-com:office:exce l"
xmlns:ss="urn:s chemas-microsoft-com:office:spre adsheet"
xmlns:html="htt p://www.w3.org/TR/REC-html40">
<DocumentProper ties xmlns="urn:sche mas-microsoft-com:office:offi ce">
<Author>The Fritz Family</Author>
<LastAuthor>com 6</LastAuthor>
<Created>2008-05-17T17:58:56Z</Created>
<LastSaved>20 08-06-10T06:16:20Z</LastSaved>
<Version>10.262 5</Version>
</DocumentPropert ies>
<OfficeDocument Settings xmlns="urn:sche mas-microsoft-com:office:offi ce">
<DownloadCompon ents/>
<LocationOfComp onents HRef="file:///\\comp4\Deval%2 0(F)\Office%20X P\"/>
</OfficeDocumentS ettings>
<ExcelWorkboo k xmlns="urn:sche mas-microsoft-com:office:exce l">
<WindowHeight>1 1640</WindowHeight>
<WindowWidth>15 480</WindowWidth>
<WindowTopX>120 </WindowTopX>
<WindowTopY>135 </WindowTopY>
<ActiveSheet> 2</ActiveSheet>
<ProtectStructu re>False</ProtectStructur e>
<ProtectWindows >False</ProtectWindows>
</ExcelWorkbook>
<Worksheet ss:Name="Master Import Sheet">
<Table ss:ExpandedColu mnCount="11" ss:ExpandedRowC ount="43" x:FullColumns=" 1"
x:FullRows="1" ss:DefaultColum nWidth="54" ss:DefaultRowHe ight="15">
<Column ss:StyleID="s81 " ss:AutoFitWidth ="0" ss:Width="90.75 "/>
<Column ss:StyleID="s84 " ss:Width="49.5"/>
<Column ss:StyleID="s84 " ss:Width="51.75 "/>
<Column ss:StyleID="s84 " ss:AutoFitWidth ="0" ss:Width="81.75 "/>
<Column ss:StyleID="s84 " ss:Width="83.25 "/>
<Column ss:StyleID="s80 " ss:AutoFitWidth ="0" ss:Width="108"/>
<Column ss:StyleID="s80 " ss:AutoFitWidth ="0" ss:Width="107.2 5"/>
<Column ss:StyleID="s80 " ss:AutoFitWidth ="0" ss:Width="153.7 5"/>
<Column ss:StyleID="s80 " ss:AutoFitWidth ="0" ss:Width="127.5 "/>
<Column ss:StyleID="s75 " ss:Width="384.7 5"/>
<Column ss:Width="71.25 "/>
<Row ss:Height="17.2 5" ss:StyleID="s62 ">
<Cell ss:StyleID="s76 "><Data ss:Type="String ">Item Number</Data><Comment
ss:Author="Matt hew T. Fritz"><ss:Data
xmlns="http://www.w3.org/TR/REC-html40"><B><Fon t html:Face="Taho ma"
x:Family="Swiss " html:Size="8" html:Color="#00 0000">AUTOGENER ATED CELL</Font></B></ss:Data></Comment></Cell>
<Cell ss:StyleID="s82 "><Data ss:Type="String ">Logo ID</Data><Comment
ss:Author="Matt hew T. Fritz"><ss:Data
xmlns="http://www.w3.org/TR/REC-html40"><B><Fon t html:Face="Taho ma"
x:Family="Swiss " html:Size="8" html:Color="#00 0000">INPUT CELL</Font></B></ss:Data></Comment></Cell>
<Cell ss:StyleID="s82 "><Data ss:Type="String ">Color Id</Data><Comment
ss:Author="Matt hew T. Fritz"><ss:Data
xmlns="http://www.w3.org/TR/REC-html40"><B><Fon t html:Face="Taho ma"
x:Family="Swiss " html:Size="8" html:Color="#00 0000">INPUT CELL</Font></B></ss:Data></Comment></Cell>
<Cell ss:StyleID="s82 "><Data ss:Type="String ">Style/Unit Id</Data><Comment
ss:Author="Matt hew T. Fritz"><ss:Data
xmlns="http://www.w3.org/TR/REC-html40"><B><Fon t html:Face="Taho ma"
x:Family="Swiss " html:Size="8" html:Color="#00 0000">INPUT CELL</Font></B></ss:Data></Comment></Cell>
<Cell ss:StyleID="s82 "><Data ss:Type="String ">Descripto r ID</Data><Comment
ss:Author="Matt hew T. Fritz"><ss:Data
xmlns="http://www.w3.org/TR/REC-html40"><B><Fon t html:Face="Taho ma"
x:Family="Swiss " html:Size="8" html:Color="#00 0000">INPUT CELL</Font></B></ss:Data></Comment></Cell>
<Cell ss:StyleID="s77 "><Data ss:Type="String ">Design/Logo Name</Data><Comment
ss:Author="Matt hew T. Fritz"><ss:Data
xmlns="http://www.w3.org/TR/REC-html40"><B><Fon t html:Face="Taho ma"
x:Family="Swiss " html:Size="8" html:Color="#00 0000">AUTOGENER ATED CELL</Font></B></ss:Data></Comment></Cell>
<Cell ss:StyleID="s77 "><Data ss:Type="String ">Color Name</Data><Comment
ss:Author="Matt hew T. Fritz"><ss:Data
xmlns="http://www.w3.org/TR/REC-html40"><B><Fon t html:Face="Taho ma"
x:Family="Swiss " html:Size="8" html:Color="#00 0000">AUTOGENER ATED CELL</Font></B></ss:Data></Comment></Cell>
<Cell ss:StyleID="s77 "><Data ss:Type="String ">Style/Unit Name</Data><Comment
ss:Author="Matt hew T. Fritz"><ss:Data
xmlns="http://www.w3.org/TR/REC-html40"><B><Fon t html:Face="Taho ma"
x:Family="Swiss " html:Size="8" html:Color="#00 0000">AUTOGENER ATED CELL</Font></B></ss:Data></Comment></Cell>
<Cell ss:StyleID="s77 "><Data ss:Type="String ">Descripto r Name</Data><Comment
ss:Author="Matt hew T. Fritz"><ss:Data
xmlns="http://www.w3.org/TR/REC-html40"><B><Fon t html:Face="Taho ma"
x:Family="Swiss " html:Size="8" html:Color="#00 0000">AUTOGENER ATED CELL</Font></B></ss:Data></Comment></Cell>
<Cell ss:StyleID="s73 "><Data ss:Type="String ">Item Name</Data><Comment
ss:Author="Matt hew T. Fritz"><ss:Data
xmlns="http://www.w3.org/TR/REC-html40"><B><Fon t html:Face="Taho ma"
x:Family="Swiss " html:Size="8" html:Color="#00 0000">AUTOGENER ATED CELL</Font></B></ss:Data></Comment></Cell>
</Row>
<Row ss:Height="15.7 5">
<Cell ss:StyleID="s78 "
ss:Formula="=CO NCATENATE((TEXT (RC[1],&quot;000&quot ;)),(TEXT(RC[2],&quot;000&quot ;)),(TEXT(RC[3],&quot;000&quot ;)),(TEXT(RC[4],&quot;000&quot ;)))"><Data
ss:Type="String ">001002002 001</Data></Cell>
<Cell ss:StyleID="s85 "><Data ss:Type="String ">001</Data></Cell>
<Cell ss:StyleID="s85 "><Data ss:Type="String ">002</Data></Cell>
<Cell ss:StyleID="s85 "><Data ss:Type="String ">002</Data></Cell>
<Cell ss:StyleID="s85 "><Data ss:Type="String ">001</Data></Cell>
<Cell ss:StyleID="s79 "
ss:Formula="=VL OOKUP(RC[-4],'DesignLogo (ABC)'!C[-5]:C[-4],2,FALSE)"><Dat a
ss:Type="String ">SW-Explorer</Data></Cell>
<Cell ss:Formula="=VL OOKUP(RC[-4],'Color (DEF)'!C[-6]:C[-5],2,FALSE)"><Dat a
ss:Type="String ">Carrot</Data></Cell>
<Cell ss:Formula="=VL OOKUP(RC[-4],'StyleUnit (GHI)'!C[-7]:C[-6],2,FALSE)"><Dat a
ss:Type="String ">Ladies Standard T-Shirt</Data></Cell>
<Cell ss:StyleID="s79 "
ss:Formula="=VL OOKUP(RC[-4],'Descriptor (JKL)'!C[-8]:C[-7],2,FALSE)"><Dat a
ss:Type="String ">Wholesale Youth XS</Data></Cell>
<Cell ss:StyleID="s74 "
ss:Formula="=CO NCATENATE(RC[-1],&quot; &quot;,RC[-2],&quot; &quot;,RC[-3],&quot; &quot;,RC[-4])"><Data
ss:Type="String ">Wholesale Youth XS Ladies Standard T-Shirt Carrot SW-Explorer</Data></Cell>
</Row>
<Row>
<Cell ss:StyleID="s78 "
ss:Formula="=CO NCATENATE((TEXT (RC[1],&quot;000&quot ;)),(TEXT(RC[2],&quot;000&quot ;)),(TEXT(RC[3],&quot;000&quot ;)),(TEXT(RC[4],&quot;000&quot ;)))"><Data
ss:Type="String ">004001003 001</Data></Cell>
<Cell ss:StyleID="s85 "><Data ss:Type="String ">004</Data></Cell>
<Cell ss:StyleID="s85 "><Data ss:Type="String ">001</Data></Cell>
<Cell ss:StyleID="s85 "><Data ss:Type="String ">003</Data></Cell>
<Cell ss:StyleID="s85 "><Data ss:Type="String ">001</Data></Cell>
<Cell ss:StyleID="s79 "
ss:Formula="=VL OOKUP(RC[-4],'DesignLogo (ABC)'!C[-5]:C[-4],2,FALSE)"><Dat a
ss:Type="String ">SW-Animal</Data></Cell>
<Cell ss:Formula="=VL OOKUP(RC[-4],'Color (DEF)'!C[-6]:C[-5],2,FALSE)"><Dat a
ss:Type="String ">Khaki Green</Data></Cell>
<Cell ss:Formula="=VL OOKUP(RC[-4],'StyleUnit (GHI)'!C[-7]:C[-6],2,FALSE)"><Dat a
ss:Type="String ">Unisex Recycled T-Shirt</Data></Cell>
<Cell ss:StyleID="s79 "
ss:Formula="=VL OOKUP(RC[-4],'Descriptor (JKL)'!C[-8]:C[-7],2,FALSE)"><Dat a
ss:Type="String ">Wholesale Youth XS</Data></Cell>
<Cell ss:StyleID="s74 "
ss:Formula="=CO NCATENATE(RC[-1],&quot; &quot;,RC[-2],&quot; &quot;,RC[-3],&quot; &quot;,RC[-4])"><Data
ss:Type="String ">Wholesale Youth XS Unisex Recycled T-Shirt Khaki Green SW-Animal</Data></Cell>
</Row>
<Row>
<Cell ss:StyleID="s78 "
ss:Formula="=CO NCATENATE((TEXT (RC[1],&quot;000&quot ;)),(TEXT(RC[2],&quot;000&quot ;)),(TEXT(RC[3],&quot;000&quot ;)),(TEXT(RC[4],&quot;000&quot ;)))"><Data
ss:Type="String ">002004001 002</Data></Cell>
<Cell ss:StyleID="s85 "><Data ss:Type="String ">002</Data></Cell>
<Cell ss:StyleID="s85 "><Data ss:Type="String ">004</Data></Cell>
<Cell ss:StyleID="s85 "><Data ss:Type="String ">001</Data></Cell>
<Cell ss:StyleID="s85 "><Data ss:Type="String ">002</Data></Cell>
<Cell ss:StyleID="s79 "
ss:Formula="=VL OOKUP(RC[-4],'DesignLogo (ABC)'!C[-5]:C[-4],2,FALSE)"><Dat a
ss:Type="String ">SW-Aid</Data></Cell>
<Cell ss:Formula="=VL OOKUP(RC[-4],'Color (DEF)'!C[-6]:C[-5],2,FALSE)"><Dat a
ss:Type="String ">Mocha</Data></Cell>
<Cell ss:Formula="=VL OOKUP(RC[-4],'StyleUnit (GHI)'!C[-7]:C[-6],2,FALSE)"><Dat a
ss:Type="String ">Unisex Standard T-Shirt</Data></Cell>
<Cell ss:StyleID="s79 "
ss:Formula="=VL OOKUP(RC[-4],'Descriptor (JKL)'!C[-8]:C[-7],2,FALSE)"><Dat a
ss:Type="String ">Wholesale Youth S</Data></Cell>
<Cell ss:StyleID="s74 "
ss:Formula="=CO NCATENATE(RC[-1],&quot; &quot;,RC[-2],&quot; &quot;,RC[-3],&quot; &quot;,RC[-4])"><Data
ss:Type="String ">Wholesale Youth S Unisex Standard T-Shirt Mocha SW-Aid</Data></Cell>
</Row>

</Table>
<WorksheetOptio ns xmlns="urn:sche mas-microsoft-com:office:exce l">
<PageSetup>
<Header x:Margin="0.3"/>
<Footer x:Margin="0.3"/>
<PageMargins x:Bottom="0.75" x:Left="0.7" x:Right="0.7" x:Top="0.75"/>
</PageSetup>
<Print>
<ValidPrinterIn fo/>
<HorizontalReso lution>-3</HorizontalResol ution>
<VerticalResolu tion>-3</VerticalResolut ion>
</Print>
<Zoom>85</Zoom>
<Panes>
<Pane>
<Number>3</Number>
<RangeSelection >C1</RangeSelection>
</Pane>
</Panes>
<ProtectObjects >False</ProtectObjects>
<ProtectScenari os>False</ProtectScenario s>
</WorksheetOption s>
</Worksheet>
<Worksheet ss:Name="Design Logo (ABC)">
<Table ss:ExpandedColu mnCount="2" ss:ExpandedRowC ount="61" x:FullColumns=" 1"
x:FullRows="1" ss:DefaultColum nWidth="54" ss:DefaultRowHe ight="14.25">
<Column ss:StyleID="s93 " ss:Width="98.25 "/>
<Column ss:StyleID="s70 " ss:Width="122.2 5"/>
<Row ss:Height="15" ss:StyleID="s72 ">
<Cell ss:StyleID="s92 "><Data ss:Type="String ">Design/Logo ID</Data></Cell>
<Cell ss:StyleID="s71 "><Data ss:Type="String ">Design/Logo Name</Data></Cell>
</Row>
<Row>
<Cell ss:StyleID="s86 "><Data ss:Type="String ">000</Data></Cell>
<Cell ss:StyleID="s69 "><Data ss:Type="String ">Test Logo</Data></Cell>
</Row>
<Row>
<Cell ss:StyleID="s86 "><Data ss:Type="String ">001</Data></Cell>
<Cell ss:StyleID="s69 "><Data ss:Type="String ">SW-Explorer</Data></Cell>
</Row>
<Row>
<Cell ss:StyleID="s86 "><Data ss:Type="String ">002</Data></Cell>
<Cell ss:StyleID="s69 "><Data ss:Type="String ">SW-Aid</Data></Cell>
</Row>
<Row>
<Cell ss:StyleID="s86 "><Data ss:Type="String ">003</Data></Cell>
<Cell ss:StyleID="s69 "><Data ss:Type="String ">SW-Service</Data></Cell>
</Row>
<Row>
<Cell ss:StyleID="s86 "><Data ss:Type="String ">004</Data></Cell>
<Cell ss:StyleID="s69 "><Data ss:Type="String ">SW-Animal</Data></Cell>
</Row>

</Table>
<WorksheetOptio ns xmlns="urn:sche mas-microsoft-com:office:exce l">
<PageSetup>
<Header x:Margin="0.3"/>
<Footer x:Margin="0.3"/>
<PageMargins x:Bottom="0.75" x:Left="0.7" x:Right="0.7" x:Top="0.75"/>
</PageSetup>
<Panes>
<Pane>
<Number>3</Number>
<RangeSelection >C1</RangeSelection>
</Pane>
</Panes>
<ProtectObjects >False</ProtectObjects>
<ProtectScenari os>False</ProtectScenario s>
</WorksheetOption s>
</Worksheet>
<Worksheet ss:Name="Color (DEF)">
<Table ss:ExpandedColu mnCount="2" ss:ExpandedRowC ount="61" x:FullColumns=" 1"
x:FullRows="1" ss:DefaultColum nWidth="54" ss:DefaultRowHe ight="14.25">
<Column ss:StyleID="s93 "/>
<Column ss:StyleID="s70 " ss:Width="80.25 "/>
<Row ss:Height="15" ss:StyleID="s72 ">
<Cell ss:StyleID="s92 "><Data ss:Type="String ">Color ID</Data></Cell>
<Cell ss:StyleID="s71 "><Data ss:Type="String ">Color Name</Data></Cell>
</Row>
<Row>
<Cell ss:StyleID="s86 "><Data ss:Type="String ">000</Data></Cell>
<Cell ss:StyleID="s69 "><Data ss:Type="String ">Custom Choice</Data></Cell>
</Row>
<Row>
<Cell ss:StyleID="s86 "><Data ss:Type="String ">001</Data></Cell>
<Cell ss:StyleID="s69 "><Data ss:Type="String ">Khaki Green</Data></Cell>
</Row>
<Row>
<Cell ss:StyleID="s86 "><Data ss:Type="String ">002</Data></Cell>
<Cell ss:StyleID="s69 "><Data ss:Type="String ">Carrot</Data></Cell>
</Row>
<Row>
<Cell ss:StyleID="s86 "><Data ss:Type="String ">003</Data></Cell>
<Cell ss:StyleID="s69 "><Data ss:Type="String ">Chrome</Data></Cell>
</Row>
<Row>
<Cell ss:StyleID="s86 "><Data ss:Type="String ">004</Data></Cell>
<Cell ss:StyleID="s69 "><Data ss:Type="String ">Mocha</Data></Cell>
</Row>

</Table>
<WorksheetOptio ns xmlns="urn:sche mas-microsoft-com:office:exce l">
<PageSetup>
<Header x:Margin="0.3"/>
<Footer x:Margin="0.3"/>
<PageMargins x:Bottom="0.75" x:Left="0.7" x:Right="0.7" x:Top="0.75"/>
</PageSetup>
<Selected/>
<Panes>
<Pane>
<Number>3</Number>
<ActiveCol>1</ActiveCol>
<RangeSelection >C2</RangeSelection>
</Pane>
</Panes>
<ProtectObjects >False</ProtectObjects>
<ProtectScenari os>False</ProtectScenario s>
</WorksheetOption s>
</Worksheet>
<Worksheet ss:Name="StyleU nit (GHI)">
<Table ss:ExpandedColu mnCount="2" ss:ExpandedRowC ount="27" x:FullColumns=" 1"
x:FullRows="1" ss:DefaultColum nWidth="54" ss:DefaultRowHe ight="14.25">
<Column ss:StyleID="s90 " ss:Width="79.5"/>
<Column ss:StyleID="s68 " ss:Width="154.5 "/>
<Row ss:Height="15.7 5" ss:StyleID="s65 ">
<Cell ss:StyleID="s88 "><Data ss:Type="String ">Style/Unit ID</Data></Cell>
<Cell ss:StyleID="s64 "><Data ss:Type="String ">Style/Unit Name</Data></Cell>
</Row>
<Row ss:StyleID="s63 ">
<Cell ss:StyleID="s87 "><Data ss:Type="String ">000</Data></Cell>
<Cell ss:StyleID="s66 "><Data ss:Type="String ">Test Style</Data></Cell>
</Row>
<Row ss:StyleID="s63 ">
<Cell ss:StyleID="s87 "><Data ss:Type="String ">001</Data></Cell>
<Cell ss:StyleID="s66 "><Data ss:Type="String ">Unisex Standard T-Shirt</Data></Cell>
</Row>
<Row ss:StyleID="s63 ">
<Cell ss:StyleID="s87 "><Data ss:Type="String ">002</Data></Cell>
<Cell ss:StyleID="s66 "><Data ss:Type="String ">Ladies Standard T-Shirt</Data></Cell>
</Row>
<Row ss:StyleID="s63 ">
<Cell ss:StyleID="s87 "><Data ss:Type="String ">003</Data></Cell>
<Cell ss:StyleID="s66 "><Data ss:Type="String ">Unisex Recycled T-Shirt</Data></Cell>
</Row>

</Table>
<WorksheetOptio ns xmlns="urn:sche mas-microsoft-com:office:exce l">
<PageSetup>
<Header x:Margin="0.3"/>
<Footer x:Margin="0.3"/>
<PageMargins x:Bottom="0.75" x:Left="0.7" x:Right="0.7" x:Top="0.75"/>
</PageSetup>
<Print>
<ValidPrinterIn fo/>
<HorizontalReso lution>600</HorizontalResol ution>
<VerticalResolu tion>600</VerticalResolut ion>
</Print>
<Panes>
<Pane>
<Number>3</Number>
<ActiveRow>7</ActiveRow>
</Pane>
</Panes>
<ProtectObjects >False</ProtectObjects>
<ProtectScenari os>False</ProtectScenario s>
</WorksheetOption s>
</Worksheet>
<Worksheet ss:Name="Descri ptor (JKL)">
<Table ss:ExpandedColu mnCount="2" ss:ExpandedRowC ount="102" x:FullColumns=" 1"
x:FullRows="1" ss:DefaultColum nWidth="54" ss:DefaultRowHe ight="14.25">
<Column ss:StyleID="s90 " ss:Width="87.75 "/>
<Column ss:StyleID="s68 " ss:Width="154.5 "/>
<Row ss:Height="15.7 5">
<Cell ss:StyleID="s88 "><Data ss:Type="String ">Descripto r ID</Data></Cell>
<Cell ss:StyleID="s64 "><Data ss:Type="String ">Style/Unit Name</Data></Cell>
</Row>
<Row>
<Cell ss:StyleID="s87 "><Data ss:Type="String ">000</Data></Cell>
<Cell ss:StyleID="s66 "/>
</Row>
<Row>
<Cell ss:StyleID="s87 "><Data ss:Type="String ">001</Data></Cell>
<Cell ss:StyleID="s66 "><Data ss:Type="String ">Wholesale Youth XS</Data></Cell>
</Row>
<Row>
<Cell ss:StyleID="s87 "><Data ss:Type="String ">002</Data></Cell>
<Cell ss:StyleID="s66 "><Data ss:Type="String ">Wholesale Youth S</Data></Cell>
</Row>
<Row>
<Cell ss:StyleID="s87 "><Data ss:Type="String ">003</Data></Cell>
<Cell ss:StyleID="s66 "><Data ss:Type="String ">Wholesale Youth M</Data></Cell>
</Row>
<Row>
<Cell ss:StyleID="s87 "><Data ss:Type="String ">004</Data></Cell>
<Cell ss:StyleID="s66 "><Data ss:Type="String ">Wholesale Youth L</Data></Cell>
</Row>

</Table>
<WorksheetOptio ns xmlns="urn:sche mas-microsoft-com:office:exce l">
<PageSetup>
<Header x:Margin="0.3"/>
<Footer x:Margin="0.3"/>
<PageMargins x:Bottom="0.75" x:Left="0.7" x:Right="0.7" x:Top="0.75"/>
</PageSetup>
<Panes>
<Pane>
<Number>3</Number>
<ActiveRow>7</ActiveRow>
</Pane>
</Panes>
<ProtectObjects >False</ProtectObjects>
<ProtectScenari os>False</ProtectScenario s>
</WorksheetOption s>
</Worksheet>
</Workbook>

How to read this multiple worksheets?
Help me pls.
Thanks
Jun 10 '08 #1
3 6235
r035198x
13,262 MVP
Since you've already exported all the sheets, couldn't you then just read that XML file using something like DOM?
Jun 10 '08 #2
sejal17
56 New Member
Since you've already exported all the sheets, couldn't you then just read that XML file using something like DOM?
thanks for your response..

here is my php file,by using it i m retrieving data of xml but only one worksheet.I want to retrieve all worksheets data.

Expand|Select|Wrap|Line Numbers
  1.  <?php
  2.  
  3.   $data = array();
  4.   include 'classes/ez_sql.php';
  5.   function import($itemno,$logoid,$colorid,$styleid,$descriptorid,$logoname,$colorname,$stylename,$descriptorname,$itemname)
  6.   {
  7.        $q1="insert into         temp(id,item_number,logo_id,color_id,style_id,descriptor_id,logo_name,color_name,style_name,descriptor_name,item_name) values('','$itemno','$logoid','$colorid','$styleid','$descriptorid','$logoname','$colorname','$stylename','$descriptorname','$itemname')";
  8.       mysql_query($q1);
  9.   } 
  10.   if ( $_FILES['file']['tmp_name'] )
  11.   {
  12.   $dom = DOMDocument::load( $_FILES['file']['tmp_name'] );
  13.   $rows = $dom->getElementsByTagName( 'Row' );
  14.   $first_row = true;
  15.   $i = 0;
  16.   foreach ($rows as $row)
  17.   {
  18.       if ( !$first_row )
  19.       {
  20.           $itemno = "";$logoid = "";$colorid = "";$styleid = "";
  21.         $descriptorid = "";$logoname = "";$colorname = "";$stylename = "";
  22.         $descriptorname = "";$itemname ="";
  23.  
  24.           $index = 1;
  25.          $cells = $row->getElementsByTagName( 'Cell' );
  26.           foreach( $cells as $cell )
  27.           {
  28.                   if ( $index == 1 )
  29.                 {    
  30.                     $itemno = $cell->nodeValue;
  31.                 }
  32.                 if($itemno != '000000000000')        
  33.                 {    
  34.                     if( $index == 2 ){  $logoid = $cell->nodeValue; }
  35.                     if($logoid != '000')
  36.                     {
  37.                         if( $index == 3 ){ $colorid = $cell->nodeValue; }    
  38.                         if($colorid != '000')
  39.                         {
  40.                             if( $index == 4 ){ $styleid = $cell->nodeValue; }    
  41.                             if($styleid != '000')
  42.                             {
  43.                                 if( $index == 5 ){ $descriptorid = $cell->nodeValue; }    
  44.                                 if( $index == 6 ){ $logoname = $cell->nodeValue; }    
  45.                                 if( $index == 7 ){ $colorname = $cell->nodeValue; }
  46.                                 if( $index == 8 ){ $stylename = $cell->nodeValue; }    
  47.                                 if( $index == 9 ){ $descriptorname = $cell->nodeValue; }
  48.                                 if( $index == 10 ){ $itemname = $cell->nodeValue; }    
  49.                             }
  50.                             else
  51.                             { exit; }    
  52.                         }
  53.                         else
  54.                         {} //exit; }
  55.                     }
  56.                     else
  57.                     { }//exit; }
  58.                 }    
  59.                 else
  60.                 { exit; }                
  61.             $index += 1;    
  62.         }              
  63.  
  64.           import($itemno,$logoid,$colorid,$styleid,$descriptorid,$logoname,$colorname,$stylename,$descriptorname,$itemname);    
  65.   }$first_row = false;
  66.  
  67.   }
  68.   }
  69.  
  70.   ?>
Please help me..
Jun 10 '08 #3
Atli
5,058 Recognized Expert Expert
I would recommend using the SimpleXML functions rather than DOM. So much simpler. (Check out the examples).

In your code, what is up with all the exit calls in you loop there?
Would it not be better to use the continue keyword?

Also, rather than having multiple if statements checking you index, and assign a value to a fixed variable based on that, consider using an array. Like:
Expand|Select|Wrap|Line Numbers
  1. $data = array();
  2. $index = 0;
  3. foreach($cells as $cell) {
  4.   $data[$index] = $cell->nodeValue;
  5.   ++$index;
  6. }
  7. saveData($data[0], $data[1], $data[2], etc..);
  8.  
Jun 11 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

10
2526
by: sarunnio | last post by:
How do I read an excel file to display the worksheet on the web. Can I make use of some excel automation to programmatically manipulate the excel file via the web browser. Thanks in advance. What I 'd like to do is to create a link like shown below. -Link1
0
4685
by: Peter | last post by:
I am having a problem reading an Excel file that is XML based. The directory I am reading contains Excel files that can be of two types. Either generic Microsoft based or XML based. I am reading the Microsoft based files with an OleDbDataAdapter. Then filling the contents of the first worksheet into a dataset. However when I try to add the...
1
4618
by: Esmail Bonakarian | last post by:
Greetings all, What is the best way to access specific records in an Excel file? I have an Excel file, I want to randomly and repeatedly (maybe around up to 50 times) draw some rows of data from this Excel file and store them in a struct/class for further processing. (mostly just display the info in graphical format) This is not some...
4
8701
by: paul.chae | last post by:
I have a table in Access with about 3000 records. There are ~60 unique values in the ID field for the 3000 records. What I would like to do is automatically generate multiple Excel worksheets within a single workbook with these records. I would end up with around 500 worksheets, 1 for each unique ID value. I was thinking this could be...
0
3643
by: c0dergirl | last post by:
This c# program allows you to select multiple items from a listbox. For each selected item, a worksheet is created in the workbook with some information. Right now I create a chart that plots some information from one of the sheets. What I want to do is have a line on the graph for every sheet. I assume I use multiple datasources to do this,...
1
9767
by: smaczylo | last post by:
Hello, I've recently been asked to work with Microsoft Access, and while I feel quite comfortable with Excel, I'm at a complete loss with databases. If someone could help me with this issue I'm having I'd be most appreciative. The database is already constructed, I'm just wanting to export the data to an excel file. In short, I'm hoping...
0
12799
by: ntuyen01 | last post by:
Hi All, I try to read the data from the excel, but I ran into this problem I have two excel files. file one.xls data inside like this: 1234 1234 1234 1234 abc-123 abc-123
0
1418
by: nudrat | last post by:
I have added a reference Microsoft Excel 5.0 Object Library in my project. the code is as follows: Dim myExcel As Excel.Application ' Interface to Excel Dim myWorkBookCollection As Excel.Workbooks ' Workbook-collection Dim myWorkBook As Excel.Workbook ' Single Workbook (spreadsheet-collection) Dim myWorkSheet As Excel.Worksheet '...
3
5383
by: sejal17 | last post by:
hello Can any one tell me how to read multiple worksheets from a single excel file.I have stored that excel in xml file.so i want to read that xml that has multiple worksheet.And i want to store that multiple worksheet data in different table.How can i do it.Below is my xml file. <?xml version="1.0"?> <Workbook...
0
7839
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8338
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7959
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8216
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5710
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3837
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2345
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1449
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1180
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.