1

ヘッダー情報が最低 2 行あり、その後に 0 行または数行のデータが続く複数のテーブルを出力しています...

私の問題は、テーブルがページの最後に折り返されることがあることです。

これを防ぐにはどうすればよいですか - MS Word テーブルに doNotWrap のようなプロパティがありますか?

私が使用しているコードは次のとおりです。

// it's an Account list so what follows will be account data then transactions
string[] sValues = pqRequests[s].Split('\t');

if (sValues[0]=="01")
                                               {
iTable++;
// output header info
if (newTable==true)
{
int rowsToGoDown = 2;
if (!firstTable)
{
oWord.Selection.MoveDown(WdUnits.wdLine, rowsToGoDown);
firstTable = true;
}

oWord.Selection.Tables[1].Select();
oWord.Selection.Copy();
oWord.Selection.MoveDown(WdUnits.wdLine, 1);
oWord.Selection.TypeParagraph();

oWord.Selection.PasteAndFormat(WdRecoveryType.wdFormatOriginalFormatting);

// remove all the excess rows
if (oWord.Selection.Tables[1].Rows.Count>2)
{
int rowsToRemove = oWord.Selection.Tables[1].Rows.Count - 3;


if (!pqRequests[s+1].StartsWith("02"))
{
rowsToRemove = oWord.Selection.Tables[1].Rows.Count - 2;
}

oWord.Selection.MoveUp(WdUnits.wdLine, rowsToRemove, WdMovementType.wdExtend);
oWord.Selection.Rows.Delete();
}

}

oWordDoc.Tables[iTable].Cell(2, 1).Range.Text = sValues[1]; // Account number
oWordDoc.Tables[iTable].Cell(2, 2).Range.Text = sValues[2]; // Account Type
oWordDoc.Tables[iTable].Cell(2, 3).Range.Text = sValues[3]; // Account Currency
oWordDoc.Tables[iTable].Cell(2, 4).Range.Text = sValues[4]; // Account Balance
iRow = 4;
newTable = true;
}

else
{
// Transaction List

if (oWordDoc.Tables[iTable].Rows.Count<3)
// we need to get a row from another table and copy it
                                                   {
oWordDoc.Tables[iSavedTable].Select();
oWord.Selection.Rows[iSavedRow].Select();
oWord.Selection.Copy();
oWordDoc.Tables[iTable].Select();

oWord.Selection.MoveDown(WdUnits.wdLine, 1);
oWord.Selection.PasteAndFormat(WdRecoveryType.wdFormatOriginalFormatting);
}

for (int iDx = 2; iDx <= 5; iDx++)
{
oWordDoc.Tables[iTable].Cell(iRow, iDx).Range.Text = sValues[iDx - 1];
}

// only add a row if the next line is another transaction line
if (pqRequests[s+1].StartsWith("02"))
{
oWordDoc.Tables[iTable].Rows.Add(ref oMissing);
iSavedTable = iTable;
iSavedRow=oWordDoc.Tables[iTable].Rows.Count-1;
                                               }
                                               iRow++;
                                            }
                                        }
                                        else
                {
                string[] sValues = pqRequests[s].Split('\t');


                // Transaction List
                for (int iDx = 2; iDx <= 5; iDx++)
                {
                oWordDoc.Tables[2].Cell(iRow, iDx).Range.Text = sValues[iDx - 1];
                }

        oWordDoc.Tables[2].Rows.Add(ref oMissing);
        iRow++;
    }

}
4

1 に答える 1

2

使用するプロパティはテーブルになく、現在の段落に配置されており、KeepWithNextKeepLinesTogether です。

これらは true に設定する必要がありますが、相互運用の優れた伝統では、ブール値は受け入れられず、intでなければなりません。また、相互運用の優れた伝統では一貫性がなく、true の値は実際には-1です。

于 2013-12-23T12:54:54.993 に答える