Randall,
i noticed you're using the PowerPoint object directly. another
suggestion then might be to use the COM object's for office to build a
word doc (or whatever format) on the server side, then send it to the
client via the binary write sample from earlier. you can accomplish
this using the Office PIAs (primary interop assemblies):
http://www.microsoft.com/downloads/...1E-3060-4F71-A6B4-01FEBA508E52&displaylang=en
also, make sure you read through the known issues first so you avoid
spinning your wheels:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnoxpta/html/odc_piaissues.asp
hope this helps,
Mike MacMillan
Randall Arnold wrote:
Wow! you sure went to a lot of effort there and I really appreciate
it.
Just hope it works!
What's extremely frustrating for me here is that one line of code is
all
it
takes to get my chart object to the clipboard, to wit:
Clipboard.SetImage(Chart1.GetChartBitmap)
After that, a simple paste operation gets it into Powerpoint:
objPres.Slides(1).Shapes.PasteSpecial(Microsoft.Office.Interop.PowerPoint.PpPasteDataType.ppPasteBitmap,
Microsoft.Office.Core.MsoTriState.msoFalse)
That was all I was looking for, but darned if I could make the
quivalent
method (SetDataObject) work for an html table. I'm still blown away
by
the
fact that Microsoft made this so difficult! But maybe I shouldn't be
by
now.
Anyway, I'll give your suggestion a shot! Thanks again.
Randall
Randall,
ive included a simple page that binary writes the rendered html of
a
table to the client using the contentType application/msword.
obviously, this is the most basic example, but should be enough to
get
you going. let me know if you have any questions.
<%@ page language="c#" inherits="System.Web.UI.Page"
autoEventWireup="true" %>
<%@ import namespace="System.IO" %>
<%@ import namespace="System.Text" %>
<%@ import namespace="System.Web.UI" %>
<script runat="server">
void OnExportData(object sender, EventArgs e) {
StringWriter sw;
HtmlTextWriter html;
byte[] arStuff;
//** create our output stream and htmltextwriter
sw = new StringWriter();
html = new HtmlTextWriter(sw);
//** get the table's rendered content
tblStuff.RenderControl(html);
sw.Flush();
//** get the byte array of the html output
arStuff = Encoding.ASCII.GetBytes(sw.ToString());
//** set the contentType and binary write to the client
Response.Clear();
Response.ContentType = "application/msword";
Response.AddHeader("Content-Disposition", "inline");
Response.AddHeader("Content-Length", ""+ arStuff.Length);
Response.BinaryWrite(arStuff);
Response.End();
}
</script>
<html>
<head>
<style type="text/css">
tr.columnHeaders td { background-color: #eee; font-weight:
bold; }
</style>
</head>
<body>
<form runat="server">
<table border="0" width="100%" cellpadding="2" cellspacing="0"
id="tblStuff" runat="server">
<tr class="columnHeaders">
<td>Column 1</td>
<td>Column 2</td>
<td>Column 3</td>
<td>Column 4</td>
</tr>
<tr>
<td>test data 01</td>
<td>test data 02</td>
<td>test data 03</td>
<td>test data 04</td>
</tr>
<tr>
<td>test data 11</td>
<td>test data 12</td>
<td>test data 13</td>
<td>test data 14</td>
</tr>
<tr>
<td>test data 21</td>
<td>test data 22</td>
<td>test data 23</td>
<td>test data 24</td>
</tr>
<tr>
<td>test data 31</td>
<td>test data 32</td>
<td>test data 33</td>
<td>test data 34</td>
</tr>
</table>
<asp:Button id="btnExport" text="Export Data" onclick="OnExportData"
runat="server"/>
</form>
</body>
</html>
hope this helps,
Mike MacMillan
Randall Arnold wrote:
Mike:
Your solution looks more like what I want to do than any other I've
come
across, thought of or been told to try. Unfortunately, I lack
experience
in
this area (binary writes). However, I'll certainly research it
because
everything else has failed miserably and I've almost given up
getting
this
to work.
All I really want is an asp.net web application that presents
tables
and
charts of quality reports, and allow users to publish them in
formats
with
which they are accustomed (Word, Powerpoint, et al). I never in my
wildest
dreams imagined it'd be as difficult an effort as it has turned out
to
be.
I hope I can make your suggestion work. Thanks,
Randall
Randall,
if the functionality you require is for someone to
copy-and-paste a
table from the website to word, this should be inherently
supported
with IE. my recommendation though would be to binary write the
html
for the table to the client, but change the ContentType to
application/vnd-msword or application/vnd-msexcel. ive found by
binary
writing directly to these applications and letting the os handle
which
program to open (hopefully word and excel), the html comes out
just
fine, without the need to save files or use the windows
clipboard.
let me know if this helps,
Mike MacMillan
Randall Arnold wrote:
I'm about to give up on what I thought would be a simple effort
but
figured
I'd give it one more try here.
I want to programmatically select an html table rendered on an
aspx
page
(using VB) and copy it to another application (Word, Powerpoint,
Excel,
et
al)... probably using the Windows clipboard.
So far I have a really crude method that involves saving the
table
as
an
html file, reloading it in Word, copying table to clipboard, etc
etc
etc--
but *surely* there has to be a more elegant method, ie,
accessing
the
table
as an object right off the web page and copying it from there.
Problem
is,
I can't find a single example of how to do this and the few
suggestions
I've
received aren't helpful.
So one last gasp: anyone here have any ideas?
Thanks,
Randall Arnold