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

Django forum database design

database django design notifications forum

I'm extending an existing Django forum app (DjangoBB) to allow users to opt in/out of notifications for specific forums and/or specific threads. I already have an existing notification infrastruct...

Issues Connecting to Local IIS ASP.NET site from Android Emulator

android asp.net iis android-emulator eclipse-adt

I have tried researching and tried some of the solution; however, I am not getting the connection to work. The purpose is to connect to a sample ASP.NET website called HelloHTML5 that would have a...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.