Do you want to get the whole worksheet's data as text, or just a specific cell range, or just a specific cell?
Nevertheless here is how you can get the whole worksheet's data to string by converting it to TAB format:
var workbook = ExcelFile.Load("Workbook.xls");
workbook.Worksheets.ActiveWorksheet = workbook.Worksheets[0];
var options = new CsvSaveOptions(CsvType.TabDelimited);
options.Encoding = new UTF8Encoding(false);
using (var stream = new MemoryStream())
{
workbook.Save(stream, options);
string worksheetAsText = options.Encoding.GetString(stream.ToArray());
// Do something with "worksheetAsText" ...
}
Or instead of writing into a stream you could use StringWriter, like this:
using (var writer = new StringWriter())
{
workbook.Save(writer, options);
string worksheetAsText = writer.ToString();
// Do something with "worksheetAsText" ...
}
UPDATE (for GemBox.Document, see comment below):
There are two approaches how you can do this, one is to do the similar as above and save the DocumentModel into a plain text format (TxtSaveOptions).
Another way would be to just use the following:
var document = DocumentModel.Load("Document.docx");
string documentAsText = document.Content.ToString();