Aspose 를 사용 하여 office 파일 을 Html 파일 로 변환 하고 파일 생 성
///
/// office Html
///
///
///
///
///
public static string FileToHtmlFile(string extFileName, string sourceFile, string desFile)
{
if (string.IsNullOrEmpty(sourceFile))
{
return "0";//
}
switch (extFileName.ToUpper())
{
case "PPT":
case "PPTX":
Aspose.Slides.Presentation ppt = new Aspose.Slides.Presentation(sourceFile);
ppt.Save(desFile, Aspose.Slides.Export.SaveFormat.Html);
break;
case "DOC":
case "DOCX":
Aspose.Words.Document doc = new Aspose.Words.Document(sourceFile);
doc.Save(desFile, Aspose.Words.SaveFormat.Html);
break;
//case "XLS":
//case "XLSX":
// break;
}
return "ok";
}
PPT 파일 이 생 성 된 html 에 인 코딩 인식 오류 가 발생 하여 브 라 우 저 웹 페이지 가 혼 란 스 러 워 집 니 다.
해결 방법 은 다음 과 같다.
System.IO.StreamReader sr = new System.IO.StreamReader(strFilePath);
string html = sr.ReadToEnd();
sr.Close();
System.IO.StreamWriter sw = new System.IO.StreamWriter(strFilePath, false);
//System.IO.StreamWriter sw = new System.IO.StreamWriter(strFilePath, false, Encoding.UTF8);
// : ,
html = html.Replace("", "");
//
html = html.Replace("Evaluation only", "");
html = html.Replace("Created with Aspose.Slides for .NET 2.0 14.8.1.0.", "");
html = html.Replace("Copyright 2004-2014 Aspose Pty Ltd.", "");
//html = html.Replace("Evaluation Only. Created with Aspose.Words. Copyright 2003-2014 Aspose Pty Ltd.", "");
html = html.Replace("Evaluation Only. Created with Aspose.Words. Copyright 2003-2014 Aspose Pty Ltd.", "");
html = html.Replace("This document was truncated here because it was created using Aspose.Words in Evaluation Mode.", "");
// < meta http - equiv = "X-UA-Compatible" content = "IE=9" >< meta http - equiv = "Content-Type" content = "text/html; charset=utf-8" />
sw.Write(html);
sw.Close();
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
【일상 놀이】 EXCEL의 셀에 “추첨”을 붙여 버리자오늘의 함수는 IF와 Rand입니다. 방법은 간단하고 EXCEL 셀에 다음을 씁시다. =IF(RAND()>=0.5,"당","벗어남") 쓴 후, Enter나 다른 장소를 클릭하면 이렇게 됩니다. 주의를 풀고 EXCEL...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.