Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6967399
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:18:59+00:00 2026-05-27T16:18:59+00:00

this is my first question in stackoverflow. I am trying to use PHPExcel to

  • 0

this is my first question in stackoverflow. I am trying to use PHPExcel to create an HTML table from .xlsx file. You can find my project in:
http://rahulr92.x10.mx/excel/index.php
Login with username ‘admin’ and you will find an option to ‘View Table’. That page displays a table from previously uploaded .xlsx file. I am new to PHPExcel and used some standard code I found online. Here it is:

<?php
require_once '/Classes/PHPExcel.php';
$objReader = PHPExcel_IOFactory::createReader('Excel2007');
$objReader->setReadDataOnly(true);
$objPHPExcel = $objReader->load("..\excel.xlsx");
$objWorksheet = $objPHPExcel->getActiveSheet();
$highestRow = $objWorksheet->getHighestRow(); 
$highestColumn = $objWorksheet->getHighestColumn(); 
$highestColumnIndex = PHPExcel_Cell::columnIndexFromString($highestColumn); 
$user=strtolower($_GET['user']);
$r_count=0;
echo '<table border="1">' . "\n";
for ($row = 5; $row <= $highestRow; ++$row) {
if ($row <7 || $user=="admin" || strstr(strtolower($objWorksheet->getCellByColumnAndRow(8, $row)->getValue()),$user ))
 { 
 if($row>7)$r_count++;
 for ($col = 0; $col <= $highestColumnIndex; ++$col) {
      if(PHPExcel_Shared_Date::isDateTime($objWorksheet->getCellByColumnAndRow($col,$row)))
        echo '<td>' . date("d M Y",PHPExcel_Shared_Date::ExcelToPHP($objWorksheet->getCellByColumnAndRow($col, $row))) . '</td>' ;
      else
        echo '<td>' . $objWorksheet->getCellByColumnAndRow($col, $row)->getValue() . '</td>' . "\n";
  }
   echo '</tr>' . "\n";
}
}
 echo '</table>' . "\n";
 echo "No. of Entries: ".$r_count;
?>

Sorry for the sub-optimal code. When I run the php file, I get a table and all strings in it are displayed properly but datetime and number fields are filled with seemingly random gibberish. Please have a look at it from the above link. I have done some research and found out about the isDateTime() function that way. But it isn’t working or probably is used wrongly. I am having a tight deadline for this project, so it would be great if anyone could point me in the right direction. Really sorry if the answer was very obvious. Thanks a lot in advance.
Rahul

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T16:19:00+00:00Added an answer on May 27, 2026 at 4:19 pm

    Don’t set $objReader->setReadDataOnly(true); if you want to be able to identify date/time values… Excel stores dates/times as floating point numbers, and the only way to differentiate a number from a date/time is using the format masking: isDateTime() uses that format masking to identify if a value is a number or a date/time… $objReader->setReadDataOnly(true) tells the file reader to read only the data (the numbers) and to ignore format masks, so it only reads the raw data.

    However, I’m not sure I understand exactly what you mean by “random gibberish”… numbers should still display as numbers… can you please give an example.

    EDIT

    Note that cell methods such as getFormattedValue() will return numbers as they are format masked in the workbook, so date/time values will be formatted as dates/times, numbers will be displayed with appropriate number of decimal places, thousand separators or currencies or percentages (if they had the appropriate formatting in the Excel file), so you don’t need to test for isDateTime()…. as long as $objReader->setReadDataOnly(true) wasn’t set for teh reader.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

this is my first question to stackoverflow so here it goes... I use cruise
first question to StackOverflow, please be gentle. I am trying to find the equation
This is my first question ever on StackOverflow, hurray! I can honestly say I
I'm quite new to stackoverflow and this is my first question. I am trying
This is my first question on stackoverflow. I just wonder why my getJSON code
This is my first StackOverflow question so be nice! :-) I recently came across
Greetings to all! This is my first question here on stackoverflow. I have a
First of all, sorry if this isn't an appropriate question for StackOverflow. I've tried
this is my first question here so I hope I can articulate it well
This is the first time I am posting a question on stackoverflow, so please

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.