0
如何獲取word文檔中的當前行作爲整數?這甚至有可能嗎?Word將當前行作爲整數
public void Export(string filename, string name, string value, DataGridView dg, int iRows)
{
oWord = null;
object missing = System.Reflection.Missing.Value;
object lineNo = missing;
// Get word instance.
ExportData.GetWordInstance(ref oWord);
if (oWord != null)
{
try
{
int iPos = 1;
oDocs = oWord.Documents;
// Open document.
object fileName = DirectoryFiles.OpenFile(filename);
object readOnly = false;
object isVisible = true;
object oMissing = Type.Missing;
oDoc = oDocs.Open(ref fileName, ref oMissing, false, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
ref oMissing, ref oMissing, ref oMissing);
oBookmarks = oDoc.Bookmarks;
if (name == "bookmarkPositions")
{
int rows = dg.Rows.Count * 3;
object oEndOfDoc = "bookmarkPositions");
Word.Table oTable;
Word.Range wrdRng = oDoc.Bookmarks.Item(ref oEndOfDoc).Range;
oTable = oDoc.Tables.Add(wrdRng, rows + 1, 5, ref oMissing, ref oMissing);
// ....
這就是我試圖解決我的出口...
感謝您的幫助!
什麼構成「當前行」? - 需要更多細節。 –
光標的行 – Jocelyn
例如,如果我在第50行,則需要分頁符。 – Jocelyn