Posted by office viewer on July 15th, 2008
If you are developing the destop application with the office viewer component, you can use the “IsDirty” method to verify whether the open document is modified. When the open file has any modification, the IsDirty method return TRUE. After you save the document, the IsDirty return False again.
But if you are developing the web application, you need to add some extra codes. Because you are opening a file from remote server and the component can’t watch the file like destop application.
A good method is set another variable in your application. When you save the document, you set the variable true. Any time you can judge the dirty by the IsDirty method and your own variable.
BOOL GetIsDirty(){
if(OA.IsDirty()==Flase) return False;
else return m_bDirty;
}
event OnDocumentOpened()
{
m_bDirty = false;
}
function UploadFile()
{
……
m_bDirty = False;
}
Posted by cathy on July 14th, 2008
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”);
}
Recent Comments