-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
88 lines (75 loc) · 3.71 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<?
include(".setup.php");
include("user_functions.php");
$CURRENT_SHEET = "";
function get_current_sheet(){
if(!empty($_REQUEST["sheet"]))
return $_REQUEST["sheet"];
return "main";
}
class CCC extends Controller{
function index(){
$sheet = get_current_sheet();
$max_rows = $this->_get("rows", 20);
$max_cols = $this->_get("cols", 10);
echo '<head><title>phpMyExcel Таблица '.get_current_sheet().'</title><meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>';
echo '<script src="'.Root::i()->getVar('wroot').'js/jquery-1.3.2.min.js"></script>';
echo '<script src="'.Root::i()->getVar('wroot').'js/short_ajax.js"></script>';
echo '<script src="'.Root::i()->getVar('wroot').'js/myexcel.js"></script>';
echo '<LINK REL="stylesheet" HREF="'.Root::i()->getVar('wroot').'style.css" TYPE="text/css">';
//echo "<input type='hidden' name='sheet' value='$sheet'>";
echo "<div class='toolbar'>";
echo "<div style='float:right'><a href='phpmyexcel.zip'>исходники</a> <a href='http://code.google.com/p/phpmyexcel/'>SVN</a></div>";
echo "<form method='GET'>";
echo "таблица: <input type='text' name='sheet' value='".get_current_sheet()."'>";
echo " столбцов: <input type='text' name='cols' value='$max_cols' size=2>";
echo " строк: <input type='text' name='rows' value='$max_rows' size=2>";
echo " <input type='submit' value='Открыть'>";
foreach(MyExcel::getLastSheets(10) as $one){
echo " <a style='font-size:10px' href='?sheet=$one'>$one</a>";
}
echo "</form>";
echo "</div>";
echo "<table id='excel'>";
echo "<tr>";
echo "<td colspan=100> </td>";
echo "</tr>";
echo "<tr>";
echo "<th> </th>";
for($col = 0; $col < $max_cols; $col++){
echo "<th>".chr(0x41 + $col)."</th>";
}
echo "</tr>";
for($row = 0; $row < $max_rows; $row++){
echo "<tr>";
echo "<th>".$row."</th>";
for($col = 0; $col < $max_cols; $col++){
$cellId = chr(0x41 + $col).$row;
echo "<td width=100 class='cell'>";
echo "<form id='form_{$cellId}' action='".Root::i()->getVar('wroot')."?Act=saveCell&sheet={$sheet}&cell_id={$cellId}' method='POST' onSubmit='return false;' style='margin:0; padding:0;'>";
$input_source = preg_replace("/\"/", """, MyExcel::getCellSource($sheet, $cellId));
//echo "<input name='content' class='cellinput' title='$cellId' type='text' value=\"".$input_source."\" id='$cellId' onkeypress='inputKeyPress(this, event)'>";
echo "<textarea rows='10' cols='40' name='content' class='cellinput' title='$cellId' type='text' id='$cellId' onkeypress='inputKeyPress(this, event)'>".$input_source."</textarea>";
echo "</form>";
echo "<div onclick='onCellClick(\"$cellId\")' id='{$cellId}_value' style='min-height:20px;white-space: nowrap;'>".MyExcel::getCellValue($sheet, $cellId)."</div>";
echo "</td>";
}
echo "</tr>";
}
echo "</table>";
}
function saveCell(){
$sheet = get_current_sheet();
$cell_id = $this->_get("cell_id");
$new_content = $this->_post("content");
$new_content = stripslashes($new_content);
//$new_content = iconv('utf-8','windows-1251',$new_content);
$new_content = trim($new_content);
MyExcel::setCellSource($sheet, $cell_id, $new_content);
echo MyExcel::getCellValue($sheet, $cell_id);
}
}
$c = new CCC();
$c->_bind();
?>