Я извлек некоторый текст в форме текста, я напечатал его построчно в выходной текстовый файл для просмотра, прежде чем я действительно сделаю то, что мне нужно сделать.
проблема, с которой я сталкиваюсь, заключается в том, что текст, который я извлекаю при открытии с помощью блокнота ++, я вижу, что текст разбит на несколько строк, тогда как в обычном блокноте это один большой фрагмент текста. Есть ли способ для меня, чтобы обнаружить следующую строку для меня, чтобы разбить строку?
Вот мой код
int linecounter = 1;
bool isDetailPage = false;
Application pptApplication = new Application();
Presentation pptPresentation = pptApplication.Presentations.Open(file, MsoTriState.msoFalse, MsoTriState.msoFalse, MsoTriState.msoFalse);
foreach (Slide _slide in pptPresentation.Slides) {
tempOutput.Add("- Parsing Slide " + linecounter);
foreach (Microsoft.Office.Interop.PowerPoint.Shape _shape in _slide.Shapes) {
if(_shape.HasTextFrame == MsoTriState.msoTrue) {
var textFrame = _shape.TextFrame;
if(textFrame.HasText == MsoTriState.msoTrue) {
var textRange = textFrame.TextRange;
Match match = knowldgeSlide.Match(textRange.Text.ToString());
if (match.Success) {
isDetailPage = true;
}
if(isDetailPage) { //ignore other slides
string[] lines = textRange.Text.ToString().Split(
new[] { "\n" },
StringSplitOptions.None
);
int t = 0;
foreach(string x in lines) {
tempOutput.Add("line " + t + ": " + x);
t++;
}
}
}
}
}
isDetailPage = false;
linecounter++;
}
Вот извлеченный текст из powerpoint, который я хочу разбить на 5 строк.
line 0: Identify the four benefits you gain from convergence and OTN? (Source: Identify the need for the NCS 4000 Series in the OTN Environment)
Virtualized network operations
The scalability
Reduction in transport costs
Flexibility allows operators to employ the technologies
Service contracts