Asp.Net MVC 사용.Excel 파일 용 Server.MapPath 사용 방법
기본 스타일, 테두리 등이 있고 이름이 MyExcel.xlsx 인 Excel 파일이 하나 있습니다. 그것은 내 로컬에서 "C : \ Users \ myusername \ Documents"를 엽니 다.
은 여기 내 C# 코드입니다 :
Application excel = new Application();
excel.Visible = true;
Workbook wb = excel.Workbooks.Open("MyExcel.xlsx");
Worksheet sh = wb.Sheets[1];
내가 C처럼 내 서버 2012에 내 파일을 업로드 : \ MyExcel.xlsx. 그래서 서버 쪽 MyExcel.xlsx 파일을 열고 싶습니다.
Server.MapPath("C:\MyExcel.xlsx");
"예기치 않은 M"오류가 발생합니다. 이 코드를 어떻게 수정합니까?
> string myServerPath = Server.MapPath("C:\MyExcel.xlsx");
> Application excel = new Application();
> excel.Visible = true;
> Workbook wb = excel.Workbooks.Open(myServerPath);
> Worksheet sh = wb.Sheets[1];
는 ": \ ... C"앞에 @을 넣어 시도? – e4rthdog