Read Excel Data (Rich Excel Data)

I want to read data form an Excel file and show in html. I know there are several libraries like PHPExcel, PHP-ExelReader that do so.

But, I also want to keep the format that was in excel file. For example :

−19×10−17 J should be parsed as −19&times;10<sup>−17</sup> J And m1r1 : m2r2 as m<sub>1</sub>r<sub>1</sub> : m<sub>2</sub>r<sub>2</sub>.

Is there any library that could do so? I have googled but did not get any solution for this. Please recommend some libraries or any tutorial for this task.

Any help will be highly appreciated.

Update - I also want to store data in database.

Answers


Got the solution. It's PHPExcel.

While fetching values from cells, what i did is as following.

$value = $cell->getValue();
if($value instanceof PHPExcel_RichText)
{
    $cellValueAsString = '';
    $elements = $value->getRichTextElements();
    foreach ($elements as $element)
    {
        if ($element instanceof PHPExcel_RichText_Run) 
        {
            if ($element->getFont()->getSuperScript()) 
            {
                $cellValueAsString .= '<sup>';
            } 
            else if ($element->getFont()->getSubScript()) 
            {
                $cellValueAsString .= '<sub>';
            }
        }

        $cellText = $element->getText();
        $cellValueAsString .= htmlspecialchars($cellText);
        if ($element instanceof PHPExcel_RichText_Run) 
        {
            if ($element->getFont()->getSuperScript()) 
            {
                $cellValueAsString .= '</sup>';
            } 
            else if ($element->getFont()->getSubScript()) 
            {
                $cellValueAsString .= '</sub>';
            }
        }
    }

    $value = $cellValueAsString;
}

Need Your Help

Game Studio Connect Timeout

networking xna vmware xbox360 vmware-fusion

I realize this isn't exactly programming specific, so if this is not the place, I apologize in advance, and let me know so I can take the question down.