convert table to csv..

jika kalian punya file txt yang dibaca ke dalam sebuah table dengan mengunakan php. kalian bisa menconvert data tersebut dari table to csv. sebagai contoh gambar dibawah ini:

nah kita langsung melihat baris source codenya saja..

	<table id="test">
		<tr>
							<th scope="col" class="rounded-company">IP Source</th>
							<th scope="col" class="rounded-q1">IP Destination</th>
							<th scope="col" class="rounded-q2">Date Timestamp</th>
							<th scope="col" class="rounded-q3">Count Integer</th>
							<th scope="col" class="rounded-q4">Rtt Avarage</th>
							<th scope="col" class="rounded-q5">Rtt Min</th>
							<th scope="col" class="rounded-q6">Rtt Max</th>
							<th scope="col" class="rounded-q7">PacketLoss</th>
							<th scope="col" class="rounded-q8">Reacilbility</th>
							<th scope="col" class="rounded-q9">Jitter</th>
						
		</tr>
		<?php
		  if(!empty($rowro)){
						//$total = count($rowsArrip) - 1; //get total row with count and - 1
						$total = count($rowro) - 1;						
						//echo readLine( $filename,1);
						print "Table List Monitoring System";
						for($i=0;$i<$total;$i++){
							$lineDetails = explodeTabs($rowro[$i]);
							$line1  =  $lineDetails[0];
							$line2  =  $lineDetails[1];//source 
							$line3  =  $lineDetails[2];//destination
							$line4  =  $lineDetails[3];//collectime
							$line5  =  $lineDetails[4];//iterasi
							$line6  =  $lineDetails[5];//avarage
							$line7  =  $lineDetails[6];//packetloss
							$line8  =  $lineDetails[7];//min
							$line9  =  $lineDetails[8];//max
							$line10 =  $lineDetails[9];//avability
							$line11 =  $lineDetails[10];//jitter
							print "<tr>\n";
							print "<td>" .$line1. "</td>\n";
							print "<td>" .$line2. "</td>\n"; 
							print "<td>" .$line3. "</td>\n";
							print "<td>" .$line4. "</td>\n";
							print "<td>" .$line5. "</td>\n";
							print "<td>" .$line6. "</td>\n";
							print "<td>" .$line7. "</td>\n";
							print "<td>" .$line8. "</td>\n";
							print "<td>" .$line9. "</td>\n";
							print "<td>" .$line10. "</td>\n";
							print "<td>" .$line11. "</td>\n";
							print "</tr>\n";
						}
					}else{
						//print "Silahkan pilih list";
					}
				
				?>
	</table>
	<form action="getCSV.php" method ="post" > 
	<input type="hidden" name="csv_text" id="csv_text">
	<input type="submit" value="Get CSV File" onclick="getCSVData()">
	</form>
	

untuk code getCSV.php dapat dilihat disini table2CSV karena semua contoh diatas bersumber dari website terseb

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s