2

I have Excel Cell value and Cell position in the database table. Now I want to render these information from database table to web page.

Screenshot:

screenshot

example: database table fields are FieldValue FieldPosition

FieldValues | FieldPosition

100                 A1
200                 B1
username            C1
testing             A2

This is my table details.

Note:cell position is alpha numeric, so sorting will now works.

12
  • 6
    So have you looked at any of the libraries for working with Excel files in PHP such as PHPExcel (phpexcel.codeplex.com)? Or are you just hoping that somebody will write the code for you? Commented Jun 2, 2013 at 9:35
  • 1
    Do you have Excel style information to work with? Or is it simply a set of references and values in a database table? Commented Jun 2, 2013 at 9:36
  • Select the data from your database ordered by row than by column from cellpostion, then loop through that data echoing it into an HTML table, setting a new row every time the row reference changes Commented Jun 2, 2013 at 9:38
  • 1
    @MarkBaker:I dont want, some one get pain for me, i dont like as well. if you saying like these, then forums are not needed, forums is nothing but sharing thoughts/ideas. if some one know very much on that logic, then they dont come and ask. any way thanks for your nice suggestion, which you provided below. Commented Jun 2, 2013 at 10:03
  • 1
    @pinkpanther thanks for suggestion. PHPExcel will help us to dislay records from Excel into WEB only know. but my request is little different. i am have these cell values and cell position in the table. now i want display records from DB Table into web. Commented Jun 2, 2013 at 10:08

2 Answers 2

6

Using PHPExcel:

// Create new PHPExcel object
$objPHPExcel = new PHPExcel();

// Read data from the database and populate the PHPExcel object
$query = "SELECT cellposition, cellvalue FROM datatable";
if ($result = $mysqli->query($query)) {
    while ($row = $result->fetch_object()) {
        $objPHPExcel->getActiveSheet()
            ->setCellValue(
                $row->cellposition,
                $row->cellvalue
            );
    }
    /* free result set */
    $result->close();
}

// Write the PHPExcel object to browser as HTML
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'HTML');
$objWriter->save('php://output');
exit;
Sign up to request clarification or add additional context in comments.

Comments

0

There are existing libraries for your needs:

PS: You know, this question has been answered previously, you should use search, before asking.

8 Comments

I have suggested this to him..it seems it's not what he wants see his comment to me under the question
@Deele; @pinkpanther yes, correct, these suggested plugins are used to read the excel files, but my functionality is little different, i have these excel values, excel position in the database table, i want to render and display into web page. this output lookup and excel lookup shoule be same.
@Bharanikumar posting some screen shot might help in this case
@pinkpanther plz chk updated one. thanks
Well PHPExcel can write Excel data as HTML, so that is an option
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.