Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/308.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何通过C应用程序从Word Interop中删除删除线_C#_Ms Word_Strikethrough - Fatal编程技术网

C# 如何通过C应用程序从Word Interop中删除删除线

C# 如何通过C应用程序从Word Interop中删除删除线,c#,ms-word,strikethrough,C#,Ms Word,Strikethrough,很抱歉,如果这是一个补救问题,我确实找遍了所有地方,但在发布之前找不到答案 我有一个简单的C应用程序,可以打开一个MS Word文档,查看3列,然后插入数据库。这部分很好用 我的问题是:在一些文档中,一些文本有删除线。我要把这个拿走。我已经找遍了,很明显我遗漏了什么 具体来说,出现问题的列是名为Graphicstext的列。我只是需要删除删除删除线,我已经尝试了一些事情,但我真的不知道该怎么做。先谢谢你 foreach(Table tb in docs.Tables) { //for (

很抱歉,如果这是一个补救问题,我确实找遍了所有地方,但在发布之前找不到答案

我有一个简单的C应用程序,可以打开一个MS Word文档,查看3列,然后插入数据库。这部分很好用

我的问题是:在一些文档中,一些文本有删除线。我要把这个拿走。我已经找遍了,很明显我遗漏了什么

具体来说,出现问题的列是名为Graphicstext的列。我只是需要删除删除删除线,我已经尝试了一些事情,但我真的不知道该怎么做。先谢谢你

foreach(Table tb in docs.Tables) {
    //for (int row = 1; row <= tb.Rows.Count; row++)

    int ColumnCount = tb.Columns.Count;

    for (int row = 1; row <= tb.Rows.Count; row++) {
        PageCell = tb.Cell(row, 1);
        EnglishTextCell = tb.Cell(row, 2);
        TranslationsCell = tb.Cell(row, 3);
        GlossaryCell = tb.Cell(row, 4);
        //GraphicsCell = tb.Cell(row, 5);
        GraphicsCell = tb.Cell(row, ColumnCount);

        string Pagetext = PageCell.Range.Text;
        Pagetext = stripCellText(Pagetext);

        string Englishtext = EnglishTextCell.Range.Text.ToString();
        Englishtext = NewLineCellText(Englishtext);

        string Translationtext = TranslationsCell.Range.Text.ToString();
        Translationtext = stripCellText(Translationtext);

        string Glossarytext = GlossaryCell.Range.Text.ToString();
        Glossarytext = stripCellText(Glossarytext);

        string Graphicstext = GraphicsCell.Range.Text.ToString();
        Graphicstext = stripCellText(Graphicstext);


        string filenametouse = System.IO.Path.GetFileNameWithoutExtension(filePath);

        string file1 = filenametouse.Substring(0, 3);
        string file2 = filenametouse.Substring(3, 2);
        string file3 = file1 + "-" + file2;

        //MessageBox.Show("row should be: " + Pagetext + " " + Englishtext + " " + Translationtext + " " + Glossarytext + " " + Graphicstext);
        //wfile.WriteLine("row should be: " + Pagetext + "|" + Englishtext + "|" + Translationtext + "|" + Glossarytext + "|" + Graphicstext );
        wfile.WriteLine("row should be: " + file3 + "|" + Pagetext + "|" + Englishtext + "|" + Graphicstext);
        wfile.WriteLine("");

        string cmdText = "INSERT INTO Lesson_Info(LessonName,PageNumber,EnglishText,Graphics)VALUES(@lesson,@pagetext,@Englishtext,@Graphicstext)";

        System.Data.OleDb.OleDbCommand cmd = new System.Data.OleDb.OleDbCommand(cmdText, conn);

        cmd.Parameters.AddWithValue("@lesson", file3);
        cmd.Parameters.AddWithValue("@pagetext", Pagetext);
        cmd.Parameters.AddWithValue("@Englishtext", Englishtext);
        cmd.Parameters.AddWithValue("@Graphicstext", Graphicstext);

        cmd.ExecuteNonQuery();

        //wfile.WriteLine("row should be: " + Pagetext);
    }
}

public string stripCellText(string text) {
    return text.Replace("\r\a", "");
    //return text.Replace("\n", "");
}

我已经有一段时间没有使用API这个词了,但是你能做一些像GraphicsCell.Range.Select这样的事情吗;然后docs.Selection.Font.Strikethrough=false;我最终解决了这个问题。我真正想要的是不要看到格式化的更改或修订。docs.ActiveWindow.View.ShowFormatChanges=false;docs.ActiveWindow.View.ShowRevisionsAndComments=false;其中文档为:Microsoft.Office.Interop.Word.Document docs=Word.Documents.Openref路径、ref未命中、ref只读、ref未命中、ref未命中、ref未命中、ref未命中、ref未命中、ref未命中、ref未命中、ref未命中、ref未命中、ref未命中、ref未命中;