In Office
Viewer ActiveX Control you can use OpenFileFromStream to open a appointed
file or open a file in database.
Either you want to open an appointed
file or open a file from database, for
client side, all what you need do is the
same, like following:
m_oEdrawOfficeViewer.HttpInit();
m_oEdrawOfficeViewer.HttpAddpostString(L”DocumentID”,
L”Tester.doc”);
m_oEdrawOfficeViewer.HttpOpenFileFromStream(strDownloadPath,varOpt,varOpt,varOpt);
Before you call function
HttpOpenFileFromStream, you should do
two things, one is to initialize http
for clearing all parameters and cookies
in http, another thing is to appoint the
file or database record. And then use
HttpOpenFileFromStream to send the
request to the destinated webpage.
Before HttpOpenFileFromStream send
request, it will add a couple of
parameters automatically.
m_OAHttp.AddPostArgument(L”EDA_GETSTREAMDATA”,
L”EDA_YES”);
This couple of parameters tell the
destinated webpage OfficeViewer will
received file as stream.
At the web side, webpage will decide to
read which file or database reacord
accordding to the post parameters.
And you should add boundary flag
‘EDA_STREAMBOUNDARY’ to file data,
following is the asp.net demo.
if (Request.Params[”EDA_GETSTREAMDATA”]
== “EDA_YES”)
{
String fullFileName =
Server.MapPath(Request.Params[”DocumentID”]);
Byte[] fs =
File.ReadAllBytes(fullFileName);
Response.Write(”Get Stream
Successfully!”);
Response.Write(”EDA_STREAMBOUNDARY”);
Response.BinaryWrite(fs);
Response.Write(”EDA_STREAMBOUNDARY”);
}
|
Open a Stream from Server without temporary file in Office Viewer ActiveX Control |
| ||||||||||||||||||
