We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Text Extraction for Excel 2014

Hi i am trying to get the text for any given worksheet.

Example i have 3 worksheets and i only want the text for the 2nd worksheet.

I need to extract the text as it currently resides within the worksheet, not comma seperated.

furthermore i need to do this within memory… saving the file down and then reading the file to get the text is too slow for the current tasks and unneeded file IO.

Is this possible, if so can you provide an example?


Thanks for your posting and considering Aspose.Cells.

Please see the following code. It saves the second worksheet in text format in a memory and then extract text from memory in a string variable and prints the text on console.

I have attached the source Excel file used in this code and screenshot showing the console output for your reference.


string filePath = @“F:\Shak-Data-RW\Downloads\source.xlsx”;

//Create workbook from source file

Workbook workbook = new Workbook(filePath);

//Set second worksheet as active

workbook.Worksheets.ActiveSheetIndex = 1;

//Text save options

TxtSaveOptions opts = new TxtSaveOptions();

opts.Separator = ’ ';

//Save workbook to memory stream

MemoryStream ms = new MemoryStream();

workbook.Save(ms, opts);

//Read the stream as text

ms.Position = 0;

StreamReader sr = new StreamReader(ms);

string textOfSheet = sr.ReadToEnd();

//Print the text of sheet