Hello everyone .. I am new to this excel reading !!

Introduction: I have a link to a txt-file(or doc file) in excel file and i need to read a data present in the linked file. I can read normal text present in excel file..

Problem : but not able to read content of the linked file. Even i cant access the object ( file ) of the linked file.

please provide a way to read linked file in java . I just need to dispaly the content of linked file .

Thanks in advance .

4 Years
Discussion Span
Last Post by mayursharma

What is a "linked file"? What is the format of the bytes in the file?
If you can get the path to the file, you can read its contents in a java program. But you will need to know the format of the bytes in the file to extract any useful information from the bytes that you read.


Hello NormR1

In my excel, i made a table and under one coloum , one link to a normal text file is there.

In Microsoft Excel 2010.. I go through Insert-> Object -> create from file ->browse a text file and check a checkbox "link to file" . press ok.

Then a link is displayed on my excel sheet.. now i need to access this linked file through java code.
I can also attach the screen shorts for the excel file .


Do you have the path to the file you want to read? The drive and folder(s) to where the file is located.


Actually .. i dont know much about Excel !! but my mentor says to use it .

And i am not able to acces that object , which i have made going through above process(Insert->Object-> create from file-> .... ) !!

Attachments myexcel.png 162.34 KB

The above screen short shows what I get after going through that process
(Insert-> Object-> create from file-> browse ...)

i am not able to access that "Ask_Question.txt" . nothing is displayed when i extract that coloum through following java code..

package excelExchange;
import java.io.FileInputStream;
import java.util.Iterator;
import java.util.Vector;

import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;

public class ReadExcelFile {

        public static void main(String[] args) {

                String fileName = "C:\\Mayur\\NewsLetter\\files\\myexcel.xls";
                Vector dataHolder = ReadCSV(fileName);

        public static Vector ReadCSV(String fileName) {
                Vector cellVectorHolder = new Vector();

                try {
                        FileInputStream myInput = new FileInputStream(fileName);

                        POIFSFileSystem myFileSystem = new POIFSFileSystem(myInput);

                        HSSFWorkbook myWorkBook = new HSSFWorkbook(myFileSystem);

                        HSSFSheet mySheet = myWorkBook.getSheetAt(0);

                        Iterator rowIter = mySheet.rowIterator();

                        while (rowIter.hasNext()) {
                                HSSFRow myRow = (HSSFRow) rowIter.next();
                                Iterator cellIter = myRow.cellIterator();
                                Vector cellStoreVector = new Vector();
                                while (cellIter.hasNext()) {
                                        HSSFCell myCell = (HSSFCell) cellIter.next();
                } catch (Exception e) {
                return cellVectorHolder;

        private static void printCellDataToConsole(Vector dataHolder) {

                for (int i = 0; i < dataHolder.size(); i++) {
                        Vector cellStoreVector = (Vector) dataHolder.elementAt(i);
                        for (int j = 0; j < cellStoreVector.size(); j++) {
                                HSSFCell myCell = (HSSFCell) cellStoreVector.elementAt(j);
                                String stringCellValue = myCell.toString();
                                System.out.print(stringCellValue + "\t");

Sorry, I don't know anything about the third party packages from apache. You will have to read the API doc for those classes to see how to use them.

Edited by NormR1: n/a


thank you for ur concern NormR1 :)
I am reading this API doc. lets see what I get , but please if anybody knows about the problem .. that will be a great help !!

Thanks in advance.

This article has been dead for over six months. Start a new discussion instead.
Take the time to help us to help you. Please be thoughtful and detailed and be sure to adhere to our posting rules.