[英]How to find and replace text in header of landscape page of word document [c# word interop]?
[英]c# How can i detect end of page in a Word document with Word Interop
我正在使用c#Interop Word進行開發,並且我需要知道頁面何時結束,因為我正在創建Word Table。 行數並不總是相同的,如果頁面沒有結束,那么我必須插入一個中斷頁面。
我怎樣才能做到這一點 ?
如果您使用Streamreader
讀取Word文件,則可以執行以下操作:
string path = @"C:\..."; // the path of your word file
Streamreader sr = new Streamreader(path);
while (!sr.EndOfStream) {
// what you want to do
{
sr.Close();
如果您想知道文件的結束行,只需創建一個count
數值,然后在文件結束時檢查count
就可以了:
string path = @"C:\..."; // the path of your word file
int count = 0;
Streamreader sr = new Streamreader(path);
while (!sr.EndOfStream) {
// what you want to do
count++;
{
sr.Close();
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.