기본적으로 WWW에서 .doc 파일을 표시하고 싶습니다. 아래 코드로 데이터를 가져 오려고했습니다. .doc에서 데이터를 가져올 수는 있지만 출력 형식이 아닙니다. .DOC.doc의 잘못된 표시 형식
B 내부
데이터
C
출력 결과
A B C
내 예상 결과
B
C이다
보호 무효 Button2_Click (객체 송신자는 EventArgs E) {
Microsoft.Office.Interop.Word.ApplicationClass wordApp = new Microsoft.Office.Interop.Word.ApplicationClass();
// File Path
string strFilePath = @"C:\Users\Roy\Desktop\fypdoc.doc";
// Create obj filename to pass it as paremeter in open
object objFile = strFilePath; object objNull = System.Reflection.Missing.Value;
object objReadOnly = true;//Open Document
Microsoft.Office.Interop.Word.Document Doc = wordApp.Documents.Open(ref objFile, ref objNull, ref objReadOnly, ref objNull, ref objNull, ref objNull, ref objNull, ref objNull, ref objNull, ref objNull, ref objNull, ref objNull, ref objNull, ref objNull, ref objNull, ref objNull);
// To read each line consider each line as paragraph Docuemnt
int i = 1;
foreach (Microsoft.Office.Interop.Word.Paragraph objParagraph in Doc.Paragraphs)
{
try
{
p1.InnerHtml += Doc.Paragraphs[i].Range.Text.Replace(Environment.NewLine,"</br>");
}
catch (Exception ex) { throw ex; } i++;
} // close document and Quit Word ApplicationDoc.Close(ref objNull, ref objNull, ref objNull);
wordApp.Quit(ref objNull, ref objNull, ref objNull);
}
thanks! it work =) –