Login   Register  
PHP Classes
elePHPant
Icontem

automatic date detection

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us

      Simple XLSX  >  All threads  >  automatic date detection  >  (Un) Subscribe thread alerts  
Subject:automatic date detection
Summary:Automationc detection of date columns
Messages:19
Author:abhishek rana
Date:2013-03-11 08:40:34
Update:2013-03-17 04:30:19
 
  1 - 10   11 - 19  

  11. Re: automatic date detection   Reply   Report abuse  
Picture of abhishek rana
abhishek rana
2013-03-15 07:04:57 - In reply to message 10 from mahesh patel
you'll have to manually detect it by calling the function rowsEx , where you can see the type as 'd'

  12. Re: automatic date detection   Reply   Report abuse  
Picture of mahesh patel
mahesh patel
2013-03-15 17:41:13 - In reply to message 11 from abhishek rana
abhishe,

Thanks for the suggestion. Can you give me an example of the code?

  13. Re: automatic date detection   Reply   Report abuse  
Picture of abhishek rana
abhishek rana
2013-03-15 22:18:13 - In reply to message 12 from mahesh patel
ok so I have changed the example3 to this just to check it and its working

<?php

if (isset($_FILES['file'])) {

require_once "simplexlsx.class.php";

$xlsx = new SimpleXLSX( $_FILES['file']['tmp_name'] );
echo "<pre>".print_r( $xlsx->rowsEx(), true )."</pre>";
echo "<pre>".print_r( $xlsx->rows(), true )."</pre>";
$rows_type = $xlsx->rowsEx() ;
echo '<h1>Parsing Result</h1>';
echo '<table border="1" cellpadding="3" style="border-collapse: collapse">';

list($cols,) = $xlsx->dimension();
$i = 0;

foreach( $xlsx->rows() as $k => $r) {
// if ($k == 0) continue; // skip first row
$j = 0;
echo '<tr>';
for( $i = 0; $i < $cols; $i++){
if( isset($rows_type[$i][$j]['type'])?($rows_type[$i][$j]['type'] != 'd'):true){

echo '<td>'.( (isset($r[$i])) ? $r[$i] : '&nbsp;' ).'</td>';
}else if(isset($rows_type[$i][$j]['type']) && $rows_type[$i][$j]['type'] == 'd' && is_numeric($r[$i])){

echo '<td>'.( (isset($r[$i])) ? date("F j, Y",$xlsx->unixstamp($r[$i])) : '&nbsp;' ).'</td>';
}else{
echo '<td>'.( (isset($r[$i])) ? $r[$i] : '&nbsp;' ).'</td>';
}
$j++ ;
}
echo '</tr>';
$i++ ;
}
echo '</table>';
}

?>
<h1>Upload</h1>
<form method="post" enctype="multipart/form-data">
*.XLSX <input type="file" name="file" />&nbsp;&nbsp;<input type="submit" value="Parse" />
</form>

  14. Re: automatic date detection   Reply   Report abuse  
Picture of mahesh patel
mahesh patel
2013-03-15 23:18:55 - In reply to message 13 from abhishek rana
Thanks,

I tried your code and I get an internal server error. I modified mine and it still fails to work: I still get date strings like 41237, etc. Below is my code.


<?php


require_once "simplexlsx.class.php";

$xlsx = new SimpleXLSX( "rschedule.xlsx" );

echo '<h1>Work Schedule</h1>';
echo '<table border="1" cellpadding="3" style="border-collapse: collapse">';

list($cols,) = $xlsx->dimension();

foreach( $xlsx->rows() as $k => $r) {
// if ($k == 0) continue; // skip first row
$j = 0;
echo '<tr>';
for( $i = 0; $i < $cols; $i++){
if( isset($rows_type[$i][$j]['type'])?($rows_type[$i][$j]['type'] != 'd'):true){

echo '<td>'.( (isset($r[$i])) ? $r[$i] : '&nbsp;' ).'</td>';
}else if(isset($rows_type[$i][$j]['type']) && $rows_type[$i][$j]['type'] == 'd' && is_numeric($r[$i])){

echo '<td>'.( (isset($r[$i])) ? date("F j, Y",$xlsx->unixstamp($r[$i])) : '&nbsp;' ).'</td>';
}else{
echo '<td>'.( (isset($r[$i])) ? $r[$i] : '&nbsp;' ).'</td>';
}
$j++ ;
}
echo '</tr>';
$i++ ;
}
echo '</table>';

  15. Re: automatic date detection   Reply   Report abuse  
Picture of abhishek rana
abhishek rana
2013-03-16 11:53:58 - In reply to message 14 from mahesh patel
you forgot this line
$rows_type = $xlsx->rowsEx() ;
you have not defined the variable before using it

  16. Re: automatic date detection   Reply   Report abuse  
Picture of mahesh patel
mahesh patel
2013-03-16 15:31:02 - In reply to message 15 from abhishek rana
Thanks, I still get internal server error on both your code and then mine without or with that particular line, but when I use the example3 provided as part of the package that works. I am not sure what is going on.

  17. Re: automatic date detection   Reply   Report abuse  
Picture of abhishek rana
abhishek rana
2013-03-16 18:06:23 - In reply to message 16 from mahesh patel
then I think u have to debug it line by line , because my code is working fine on my system.

  18. Re: automatic date detection   Reply   Report abuse  
Picture of mahesh patel
mahesh patel
2013-03-17 03:58:42 - In reply to message 17 from abhishek rana
Abhishek,
I was able to get your sample script to work. It had to do with some permissions of files on the shared server I was using and your date script mods worked well. I changed them a bit to use 2 digit format.

Now it seems as though the path references to the file to load seem a bit tricky. Thanks for your help!
-M

  19. Re: automatic date detection   Reply   Report abuse  
Picture of mahesh patel
mahesh patel
2013-03-17 04:30:19 - In reply to message 18 from mahesh patel
Actually, the math seems to be off by one day with xlsx being one day before the xlsx date, so there may be an error in the transformation used.

 
  1 - 10   11 - 19