File Error: data may have been lost

Last post 04-25-2007, 9:42 AM by rohitob. 6 replies.
Sort Posts: Previous Next
  •  04-20-2007, 6:22 PM 73902

    File Error: data may have been lost

    Hi Aspose Team,

    I am using the Aspose.Cell Java version 1.8.1.0.

    I get "File Error: data may have been lost" error when I perform the following steps
    1) I open a template file (having formulas)

    2) I copy some data into 1st worksheet.

    3) Run calculate formula

    4) Save 2nd worksheet as a new excel file

    5) When I attempt to re-open the file I get the File Error: data may have been lost. I press OK and the file opens okay and it appears that nothing is missing.

     
  •  04-23-2007, 12:24 AM 73975 in reply to 73902

    Re: File Error: data may have been lost

    Hi,

    Could you attach your file and simple project ? It will help us to fix the problem.


    Warren Zhang
    Developer
    Aspose Nanjing Team
    About Us
    Contact Us
     
  •  04-23-2007, 10:34 AM 74048 in reply to 73975

    Re: File Error: data may have been lost

    Attachment: Present (inaccessible)

    Hi Warren,

     

    Please find attcahed the files. Please let me know.

     
  •  04-23-2007, 8:26 PM 74100 in reply to 74048

    Re: File Error: data may have been lost

    Hi,

    We could not find this problem. See the following testing codes:

    Workbook workbook = new Workbook();     
          workbook.open("C:\\TEST_INPUT.xls");
          Cells sourceCells = workbook.getWorksheets().getSheet(0).getCells();   
          Workbook dest = new Workbook();
          dest.open("F:\\FileTemp\\TEST_TEMPLATE.xls");
          Cells destCells = dest.getWorksheets().getSheet(0).getCells();
          for(int i = 6 ; i <= 34 ; i++ )
          {
             destCells.copyRow(sourceCells,i,i + 2);
          }
          dest.calculateFormula();
          dest.save("C:\\dest.xls");

    Please point out the difference with your codes.


    Warren Zhang
    Developer
    Aspose Nanjing Team
    About Us
    Contact Us
     
  •  04-24-2007, 8:54 AM 74196 in reply to 74100

    Re: File Error: data may have been lost

    Hi Aspose Team,

    There is a chnage in the final step. Instead of saving the whole xls I wa nted to just save the 2nd worksheet with formula values only. Below is code snippet.

    //dest.save("C:\\temp\\SOWOOD\\dest.xls");

    SaveXLSFiles(dest);

    //SaveXLSFiles Method

    public static void SaveXLSFiles(Workbook wrkBook) throws IOException{

    File outputFile = new File("C:\\temp\\SOWOOD\\dest.xls");

    FileOutputStream outputstream = new FileOutputStream(outputFile);

    Workbook outputWorkBook = new Workbook();

    Worksheet outputSheet = outputWorkBook.getWorksheets().getSheet(0);

    Worksheet templateSheet = wrkBook.getWorksheets().getSheet(1);

    Cells cells = templateSheet.getCells();

    Cells destCells = outputSheet.getCells();

    Row sourceRow,destRow;

    Cell sourceCell;

    int endRow = templateSheet.getCells().getMaxDataRow();

    for(Iterator it = cells.getRowIterator(); it.hasNext(); )

    {

    sourceRow = (Row)it.next();

    if(sourceRow.getRowIndex() > endRow){

    break;

    }

    destRow = destCells.getRow(sourceRow.getRowIndex());

    for(Iterator cellIt = sourceRow.getCellIterator(); cellIt.hasNext();)

    {

    sourceCell = (Cell)cellIt.next();

    destRow.getCell(sourceCell.getColumnIndex()).setStyle(sourceCell.getStyle());

    destRow.getCell(sourceCell.getColumnIndex()).setValue(sourceCell.getValue());

    }

    }

    outputWorkBook.save(outputstream);

    }

     

    Thanks,

    rohitob

     
  •  04-24-2007, 10:17 PM 74297 in reply to 74196

    Re: File Error: data may have been lost

    Attachment: Present (inaccessible)

    Hi,

    If you use JDK 1.5 ,please try the fix in http://www.aspose.com/COMMUNITY/Forums/74296/ShowThread.aspx#74296.

    If you use JDK 1.4, Please try this fix.


    Warren Zhang
    Developer
    Aspose Nanjing Team
    About Us
    Contact Us
     
  •  04-25-2007, 9:42 AM 74368 in reply to 74297

    Re: File Error: data may have been lost

    Thanks Warren the issue is resolved with the fix provided.  But I encountered another issue in accessing cells ..please refer to the post at http://www.aspose.com/COMMUNITY/Forums/74367/ShowThread.aspx#74367

     
View as RSS news feed in XML