Forum Moderators: open
So I found out that I can put a mini-Excel sheet on my page with this:
<object
id = 'excel'
classid = 'CLSID:0002E510-0000-0000-C000-000000000046'>
<param name="DisplayTitleBar" value="false">
</object>
now, how can I insert data into that? and if I do editing within it, how do I get the data out again?
My goal is to make this into a front-end for editing a database table.
Example: php from DB (MySQL) into Excel worksheet:
<?
$csv_output = "column 1,column2";
$csv_output .= "\n";
$result = mysql_query("select * from table");while($row = mysql_fetch_array($result)) {
$csv_output .= "$row[col1],$row[col2]\n";
}header("Content-type: application/vnd.ms-excel");
header("Content-disposition: csv" . date("Y-m-d") . ".xls");
print $csv_output;
exit;
?>
Note that multiple users will eventually cause version conflicts. This is why custom code with transaction lock/version control is usually specified and also why it is rarely done and poorly (publicly) documented.
A custom application layer is a more common user DB interface.
where "excel" is the id of my <object>,
excel.Cell(1,2).Value='3'
excel.range($A$1).Value='1'
I'm looking for any other ways to manipulate the embedded app with client-side js commands
~hww
I'll say OWC a few more times so this OWC post ranks higher for OWC the next time I'm searching for OWC.
They are abysmally documented online, almost as though Microsoft doesn't really want people to use them unless they spend $$ buying their books.
here are some nice paramters you can play with:
<object
width = 900
height = 500
id = 'excel'
classid = 'CLSID:0002E510-0000-0000-C000-000000000046' VIEWASTEXT>
<param name=DisplayTitleBar value=true >
<param name="DataType" value="CSVURL">
<param name="AutoFit" value="0">
<param name="DisplayColHeaders" value="1">
<param name="DisplayGridlines" value="1">
<param name="DisplayHorizontalScrollBar" value="1">
<param name="DisplayRowHeaders" value="1">
<param name="DisplayTitleBar" value="1">
<param name="DisplayToolbar" value="1">
<param name="DisplayVerticalScrollBar" value="1">
<param name="EnableAutoCalculate" value="0">
<param name="EnableEvents" value="0">
<param name="MoveAfterReturn" value="1">
<param name="MoveAfterReturnDirection" value="0">
<param name="RightToLeft" value="0">
</object>
I used an ASP script to write out a pile of individual javascript statements to insert values into the spreadsheet:
<script>
excel.range('a14').value = '435';
excel.range('b14').value = '0';
excel.range('c14').value = 'Downtown Businesses';
excel.range('d14').value = 'Friday';
excel.range('e14').value = '';
</script>
And I found a few interesting ways you can manipulate cells and properties:
<script>
function boldexcel(){
excel.ActiveCell.EntireRow.Font.Bold = true;
}
function excelalert(){
alert(excel.ActiveCell.Value);
}
function excelview(){
excel.ViewableRange="$A$1:$C$4";
}
</script>
The limitation of SEs is their inability to work outside of explicit terms/phrases. Have added these SE returns to a file for future study. The initial quick glance showed much I had not known on a subject I thought I knew fairly well ... thanks httpwebwitch for adding to my knowledge (and workload).