hii,
i'm using excel as my front end, so i've to show the end user the excel sheet in an editable datagrid, which now i'm using an uneditable table using php excel reader.
i've executed phpgrid but it is rendering the values from mysql table in the grid.
i wanna render excel sheet in an editable GRID.

can anyone give me suggestions.. :mad:
many thanks,

    Sounds like a job for a CSV and Dojo.

    You can get your data into a delimited fashion (i.e. CSV) and then use the DojoToolkit JavaScript library to create an editable grid easily.

    http://www.dojotoolkit.com

      You can get your data into a delimited fashion (i.e. CSV) and then use the DojoToolkit JavaScript library to create an editable grid easily.

      i havent found any datagrid in that site..
      cant we directly export excel sheet to a datagrid?

      presently i'm using PHPExcel 2007 to read and write excel files.
      i think CSV is not suitable for novice end users.so excel is preferred.

      i just want to edit the values of cells on the fly, so i need to render it in a datagrid.
      till now i found solutions for exporting mysql table query results to the GRID.
      below is the code of my present HTML table(PHP Parsed Excel sheet rendered in a html uneditable table).

      can you help me out..
      Many Thanks,

        code for parsing an excel file and rendering it in an uneditable html table.

        <?PHP
        include"authn.php";
        $allow_url_override = 1; // Set to 0 to not allow changed VIA POST or GET
        if(!$allow_url_override || !isset($file_to_include))
        {
        	$file_to_include = "/wamp/www/MyDreamProject/uploads/CSE_IYEAR_INTERNALS.xls";
        }
        if(!$allow_url_override || !isset($max_rows))
        {
        	$max_rows = 0; //USE 0 for no max
        }
        if(!$allow_url_override || !isset($max_cols))
        {
        	$max_cols = 21; //USE 0 for no max
        }
        if(!$allow_url_override || !isset($debug))
        {
        	$debug = 0;  //1 for on 0 for off
        }
        if(!$allow_url_override || !isset($force_nobr))
        {
        	$force_nobr = 1;  //Force the info in cells not to wrap unless stated explicitly (newline)
        }
        require_once 'reader.php';
        $data = new Spreadsheet_Excel_Reader();
        $data->setOutputEncoding('CPa25a');
        $data->read($file_to_include);
        error_reporting(E_ALL ^ E_NOTICE);
        echo "
        <br>
        <STYLE>
        .table_data
        {
        	border-style:ridge;
        	border-width:1;
        
        }
        .tab_base
        {
        	background:#C5D0DD;
        	font-weight:bold;
        	font-size:14;
        	font-family:Verdana;
        	//border-style:ridge;
        	//border-width:1;
        
        cursor:pointer;
        }
        .table_sub_heading
        {
        	background:#CCCCCC;
        	font-weight:normal;
        	border-style:ridge;
        	border-width:1;
        }
        .table_body
        {
        	background:#FAF9F5;
        	font-weight:normal;
        	font-size:12;
        
        color:#000000;
        font-family:Times Roman;
        border-style:ridge;
        border-width:0;
        border-spacing: 0px;
        border-collapse: collapse;
        }
        .tab_loaded
        {
        	background:#E8EEFA;
        	color:black;
        	font-weight:bold;
        	font-size:13;
        	//float:center;
        	padding: 0.2em 0.6em 0.2em 26px;
        	background: url('http://localhost/MyDreamProject/images/liahover.gif') ;
        	font-family:Times Roman;
        	//border-style:groove;
        	//border-width:1;
        	cursor:pointer;
        }
        </STYLE>
        ";
        function make_alpha_from_numbers($number)
        {
        	$numeric = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
        	if($number<strlen($numeric))
        	{
        		return $numeric[$number];
        	}
        	else
        	{
        		$dev_by = floor($number/strlen($numeric));
        		//return "" . make_alpha_from_numbers($dev_by-1) . make_alpha_from_numbers($number-($dev_by*strlen($numeric)));
        	}
        }
        echo "<SCRIPT LANGUAGE='JAVASCRIPT'>
        var sheet_HTML = Array();\n";
        for($sheet=0;$sheet<count($data->sheets);$sheet++)
        {
        	$table_output[$sheet] .= "<TABLE CLASS='table_body'>
        	<TR>
        		<TD>&nbsp;</TD>";
        	for($i=0;$i<$data->sheets[$sheet]['numCols']&&($i<=$max_cols||$max_cols==0);$i++)
        	{
        		$table_output[$sheet] .= "<TD CLASS='table_sub_heading' ALIGN=CENTER>" . make_alpha_from_numbers($i) . "</TD>";
        	}
        	for($row=1;$row<=$data->sheets[$sheet]['numRows']&&($row<=$max_rows||$max_rows==0);$row++)
        	{
        		$table_output[$sheet] .= "<TR><TD CLASS='table_sub_heading'>" . $row . "</TD>";
        		for($col=1;$col<=$data->sheets[$sheet]['numCols']&&($col<=$max_cols||$max_cols==0);$col++)
        		{
        			if($data->sheets[$sheet]['cellsInfo'][$row][$col]['colspan'] >=1 && $data->sheets[$sheet]['cellsInfo'][$row][$col]['rowspan'] >=1)
        			{
        				$this_cell_colspan = " COLSPAN=" . $data->sheets[$sheet]['cellsInfo'][$row][$col]['colspan'];
        				$this_cell_rowspan = " ROWSPAN=" . $data->sheets[$sheet]['cellsInfo'][$row][$col]['rowspan'];
        				for($i=1;$i<$data->sheets[$sheet]['cellsInfo'][$row][$col]['colspan'];$i++)
        				{
        					$data->sheets[$sheet]['cellsInfo'][$row][$col+$i]['dontprint']=1;
        				}
        				for($i=1;$i<$data->sheets[$sheet]['cellsInfo'][$row][$col]['rowspan'];$i++)
        				{
        					for($j=0;$j<$data->sheets[$sheet]['cellsInfo'][$row][$col]['colspan'];$j++)
        					{
        						$data->sheets[$sheet]['cellsInfo'][$row+$i][$col+$j]['dontprint']=1;
        					}
        				}
        			}
        			else if($data->sheets[$sheet]['cellsInfo'][$row][$col]['colspan'] >=1)
        			{
        				$this_cell_colspan = " COLSPAN=" . $data->sheets[$sheet]['cellsInfo'][$row][$col]['colspan'];
        				$this_cell_rowspan = "";
        				for($i=1;$i<$data->sheets[$sheet]['cellsInfo'][$row][$col]['colspan'];$i++)
        				{
        					$data->sheets[$sheet]['cellsInfo'][$row][$col+$i]['dontprint']=1;
        				}
        			}
        			else if($data->sheets[$sheet]['cellsInfo'][$row][$col]['rowspan'] >=1)
        			{
        				$this_cell_colspan = "";
        				$this_cell_rowspan = " ROWSPAN=" . $data->sheets[$sheet]['cellsInfo'][$row][$col]['rowspan'];
        				for($i=1;$i<$data->sheets[$sheet]['cellsInfo'][$row][$col]['rowspan'];$i++)
        				{
        					$data->sheets[$sheet]['cellsInfo'][$row+$i][$col]['dontprint']=1;
        				}
        			}
        			else
        			{
        				$this_cell_colspan = "";
        				$this_cell_rowspan = "";
        			}
        			if(!($data->sheets[$sheet]['cellsInfo'][$row][$col]['dontprint']))
        			{
        				$table_output[$sheet] .= "<TD CLASS='table_data' $this_cell_colspan $this_cell_rowspan>&nbsp;";
        				if($force_nobr)
        				{
        					$table_output[$sheet] .= "<NOBR>";
        				}
        				$table_output[$sheet] .= nl2br(htmlentities($data->sheets[$sheet]['cells'][$row][$col]));
        				if($force_nobr)
        				{
        					$table_output[$sheet] .= "</NOBR>";
        				}
        				$table_output[$sheet] .= "</TD>";
        			}
        		}
        		$table_output[$sheet] .= "</TR>";
        	}
        	$table_output[$sheet] .= "</TABLE>";
        	$table_output[$sheet] = str_replace("\n","",$table_output[$sheet]);
        	$table_output[$sheet] = str_replace("\r","",$table_output[$sheet]);
        	$table_output[$sheet] = str_replace("\t"," ",$table_output[$sheet]);
        	if($debug)
        	{
        		$debug_output = print_r($data->sheets[$sheet],true);
        		$debug_output = str_replace("\n","\\n",$debug_output);
        		$debug_output = str_replace("\r","\\r",$debug_output);
        		$table_output[$sheet] .= "<PRE>$debug_output</PRE>";
        	}
        	echo "sheet_HTML[$sheet] = \"$table_output[$sheet]\";\n";
        }
        echo "
        function change_tabs(sheet)
        {
        	//alert('sheet_tab_' + sheet);
        	for(i=0;i<" , count($data->sheets) , ";i++)
        	{
        		document.getElementById('sheet_tab_' + i).className = 'tab_base';
        	}
        	document.getElementById('table_loader_div').innerHTML=sheet_HTML[sheet];
        	document.getElementById('sheet_tab_' + sheet).className = 'tab_loaded';
        
        }
        </SCRIPT>";
        echo "
        <TABLE CLASS='table_body' NAME='tab_table'>
        <TR>";
        for($sheet=0;$sheet<count($data->sheets);$sheet++)
        {
        	echo "<TD CLASS='tab_base' ID='sheet_tab_$sheet' ALIGN=CENTER
        		ONMOUSEDOWN=\"change_tabs($sheet);\">", $data->boundsheets[$sheet]['name'] , "</TD>";
        }
        
        echo 
        "<TR>";
        echo "</TABLE>
        <DIV ID=table_loader_div></DIV>
        <SCRIPT LANGUAGE='JavaScript'>
        change_tabs(0);
        </SCRIPT>";
        //echo "<IFRAME NAME=table_loader_iframe SRC='about:blank' WIDTH=100 HEIGHT=100></IFRAME>";
        /*
        echo "<PRE>";
        print_r($data);
        echo "</PRE>";
        */
        ?>
         

          Searching for Grid on Dojo's website yields: http://www.dojotoolkit.org/book/dojo...velopment/grid

          in dojo grid, data is loaded from JSON.
          i want to load the dynamic data not predefined data using excel only.
          i succeeded in reading the excel cells, but i dunno how to put the values in a datagrid.
          please help me.. i'm goin mad really with this..:mad:

            and with that excel reader, could you write an excel? if not, you can make editable forms/tables,

            but what is the second step?

            you can save into a database, or export a CSV or XML ...

              and with that excel reader, could you write an excel? if not, you can make editable forms/tables,

              yes i can read an excel file using php excel reader, and rendering the excel sheet in an uneditable table.i've a separate code for inserting this php parsed excel sheet. that is working fine.
              i would like to add a feature of editing the grid loaded with excel sheet on fly, and the user has to save this modified as new excel and then upload it to MYSQL.

              it is all for data entity check.
              here is the snapshot of my php parsed excel sheet.
              i want to make the cells editable..
              hope u got me..

                Write a Reply...