У меня есть документ с текстовыми абзацами, а также таблицы. Я хочу найти таблицу, текст которой начинается с «Этот акт был обновлен до». В таблице есть одна ячейка. строка 1, столбец 1. Как найти эту таблицу с помощью кода. Не знаком с использованием таблиц и словосочетаний. Благодарю.Word interop using tables
0
A
ответ
1
я частично скопировали этот пример одного из моих проектов (заменен/удалить некоторый код - так он может содержит синтаксические ошибки), но если вы уже работаете с Interop и раннее связывание - это может быть полезно
using Word = Microsoft.Office.Interop.Word;
var wordApplication = new Word.Application();
var filename = "C:\test.doc";
Word.Application wordApp = null;
if (wordApplication != null)
wordApp = wordApplication as Word.ApplicationClass;
Word.Document wordDoc = null;
if (File.Exists(fileName.ToString()) && wordApp != null)
{
object readOnly = isReadonly;
object isVisible = true;
object missing = System.Reflection.Missing.Value;
wordDoc = wordApp.Documents.Open(ref fileName, ref missing,
ref readOnly, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing, ref missing,
ref missing, ref isVisible, ref missing, ref missing, ref missing,
ref missing);
}
Word.Document wordDocument = wordDoc as Word.Document;
int tablecount = wordDocument.Tables.Count;
wordDocument.Activate();
for (int i = 1; i <= tablecount; i++)
{
Word.Table wTable = wordDocument.Tables[i];
Word.Cell pCell = wTable.Cell(1, 1);
if (pCell.Range.Text == "This Act has been update to")
{
MessageBox.Show("Bingo !!!");
break;
}
}
0
NetOffice что-то предложить для вас. Другое решение - сохранить ваш текстовый файл в формате HTML, а затем использовать HTML Agility Pack.
Смежные вопросы
- 1. using interop .word with asp.net
- 2. Pivot Using 2 Tables
- 3. Как ускорить обработку Word Interop?
- 4. Graph.Chart interop in Word
- 5. word interop solid lines
- 6. Ошибка компиляции Word Interop
- 7. Word interop, table border
- 8. Word Interop Paragraph.Hyphenation values
- 9. C# Word Interop
- 10. Word Interop Not Extracting Data
- 11. Word Interop: событие для закрытия Word
- 12. Word Interop SaveAs2 как PDF
- 13. Word interop, отключение подсказки сохранения
- 14. Редактор формата через Word interop
- 15. Контурный текст с Word Interop
- 16. using Microsoft.Office.Interop Word и Excel
- 17. Word unscrambling using python
- 18. Word count using Microsoft.Office.Interop.Word
- 19. Извлечь Bullets and Tables информацию в Word doc с C#
- 20. Word Interop GetSpellingSuggestions no open document error
- 21. Как запретить пользователю редактировать Word Document wit C# Word Interop?
- 22. Открывать документы Word с помощью Interop DLL без открытия Word?
- 23. Найти и заменить Word Interop Whole Word Matching
- 24. Interop Word - Удалить страницу из документа
- 25. Word Interop Добавить закладку в заголовок
- 26. Реактивация COM AddIn с Word Interop
- 27. Замена Word Interop работает только один раз
- 28. Печать в сетевой (общий) принтер - Word Interop
- 29. Acess current document in Word interop
- 30. Microsoft Interop Word получает диапазон от заголовка