2017-11-03 2 views
1

단어 내보내기 기능을 만들려고하지만 내 콘텐츠에 html 태그가 있습니다. html 파일에이 내용을 넣었습니다. 을 &lt;으로 바꿉니다. 원하는 내용이 아닙니다.C# <을 <HTML 파일로 바꾸기

누군가가 도와 줄 수 있습니까?

나는 사무실 상호 운용성 단어를 사용하고 여기에 내가 지금 사용하는 코드입니다 : 당신이 직접 특정 HTML 태그를 사용하도록 말할 수

Microsoft.Office.Interop.Word.Application app = new Microsoft.Office.Interop.Word.Application(); 

Document doc = app.Documents.Open(FileName: @"C:\Users\example\Documents\Template.docx", ReadOnly: false); 
app.Selection.Find.Execute("<Index>"); 
app.Selection.TypeText("<h1>hello</h1>"); 

doc.SaveAs2(@"C:\Users\krisb\Documents\voorbeeld.html", FileFormat: WdSaveFormat.wdFormatWebArchive); 
doc.Close(); 

Document doc1 = app.Documents.Open(FileName: @"C:\Users\example\Documents\voorbeeld.html", ReadOnly: false); 
app.Selection.Find.Execute("&lt;"); 
app.Selection.TypeText("<"); 
app.Selection.Find.Execute("&gt;"); 
app.Selection.TypeText(">"); 

doc1.SaveAs2(@"C:\Users\example\Documents\template.docx", FileFormat: WdSaveFormat.wdFormatDocumentDefault); 
doc1.Close(); 

Document doc2 = app.Documents.Open(FileName: @"C:\Users\example\Documents\kristemplate.docx", ReadOnly: false); 
doc2.SaveAs2(@"C:\Users\example\Documents\kristemplate.pdf", FileFormat: WdSaveFormat.wdFormatPDF); 

app.Quit();` 
+1

_ "<를 <와"? – SeM

+0

아니요, html 파일을 html 파일에 넣으면 << –

+0

으로 바꿉니다. 그런 다음 해당 부분에서 질문을 수정하십시오. – SeM

답변

0

말씀은 HTML 편집기 아니다는. Word는 및 HTML 파일을 가져올 수 있습니다. 내부적으로 Word 개체 모델은 해당 개체를 Word 문서로 처리합니다.

은 무엇 작업은 HTML의 수출은 H1로 렌더링하는 방식으로 "Hello"형식으로 삽입하는 것입니다. 그게 가능할 지 모르겠지만 텍스트를 "제목 1"로 포맷하면 좋은 추측 일 수 있습니다. 직접 생성 된 HTML을 수정해야하는 경우

또는, 당신은

  • 수출 첫 번째 HTML과 같은 파일 및
  • 는 C#에서 텍스트 파일로 열고 교체해야 .
관련 문제