2011-11-16 4 views
2

난에서 엑셀 파일을 수출하고 C 어떤 대화 + asp.net 우유없는 엑셀 파일 : 같은 responce 개체 를 사용하여 "C 테스트 \ data.xls를"그것은을 여는수출 #

response.AddHeader("Content-Disposition", "attachment; filename=" + FileName + ";"); 

대화 상자가 필요 없습니다. 우리는 대화 상자없이 직접 파일을 열고 싶습니다. 어떤 신체가 나를 도울 수 있습니까

답변

0

응답 파일에 첨부하는 대신 응답 스트림에 내용을 쓰십시오.

//Set the appropriate ContentType. 
Response.ContentType = "application/vnd.ms-excel"; // not sure in content type 
//Get the physical path to the file. 
string filePath = @"c:Test\data.xls"; 
//Write the file directly to the HTTP content output stream. 
Response.WriteFile(filePath); 
Response.End(); 

또한 클라이언트 측 설정에 영향을 미칩니다.

1

사용

가 직접 열어 작업 할 수있는이 클라이언트 측 보안 설정에 따라 달라집니다하지만 보장은 없습니다 여부
response.AddHeader("Content-Disposition", "inline; filename=" + FileName + ";"); 

...