After installed the latest demo version, you can open the excel from file stream using the following code:
objExcel.HttpInit();
objExcel.HttpAddPostFile(“”,”Evaluation.xlsx”);
objExcel.HttpOpenFileFromStream(“Evaluation/EvaluationReceiver.aspx”);
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”);
}
One Response to “Open Excel From File Stream Using .NET”
Leave a Reply
You must be logged in to post a comment.
October 17th, 2008 at 12:03 pm
I am developing a Documents Manager that allows to upload office and other vendors documents to SQL Server (Blobs). I come up to serach for a component (client side) to display office documents. I’ve found this one office ocx from edrawsoft, developed in C++. Cool!