Unable to read file

Dear All,


I am evaluating Aspose Cells .NET, I downloaded the latest version 8.0.2.0, and Office 2007
I am facing with 'Unable to read file’

why?.. did I miss something in the codes below? … I enclosed the excel file…

// ===== creating Header ====

private void createXLS_MO()
{
_workbook = new Workbook();
_sheet = _workbook.Worksheets[0];

_cells = _sheet.Cells;

_sheet.Name = “Raw Data”;
_sheet.FreezePanes(1, 1, 1, 25);

_header.Font.IsBold = true;
_header.HorizontalAlignment = TextAlignmentType.Center;

_txtdetail.Font.IsBold = false;
_txtdetail.HorizontalAlignment = TextAlignmentType.Left;

_numformat.Number = 4;
_numformat.HorizontalAlignment = TextAlignmentType.Right;
_numformat.Font.IsBold = false;

_cell = _cells[“A1”];
_cell.PutValue(“Branch”);
_cell.SetStyle(_header);

_cell = _cells[“B1”];
_cell.PutValue(“MO”);
_cell.SetStyle(_header);

_cell = _cells[“C1”];
_cell.PutValue(“Source”);
_cell.SetStyle(_header);

_cell = _cells[“D1”];
_cell.PutValue(“Outstanding”);
_cell.SetStyle(_header);
_cell = _cells[“E1”];
_cell.PutValue(“Current”);
_cell.SetStyle(_header);
_cell = _cells[“F1”];
_cell.PutValue(“Overdue”);
_cell.SetStyle(_header);
}


//==== Creating Pivot ====

private void createPivot_MO()
{
try
{
Worksheet sheet2 = _workbook.Worksheets[_workbook.Worksheets.Add()];
sheet2.Name = “PivotTable”;
int filter = cboFilter.SelectedIndex;

_cells = sheet2.Cells;
_cells.Merge(0, 1, 1, 7, true, false);
_cell = _cells[“B1”];
_cell.PutValue(“Profit Comm by " + cboFilter.Text);
_cell.SetStyle(_header);

_cells.Merge(1, 1, 1, 7, true, false);
_cell = _cells[“B2”];
_cell.PutValue(_condition);
_cell.SetStyle(_header);

Aspose.Cells.Pivot.PivotTableCollection pivotTables = sheet2.PivotTables;
int index = pivotTables.Add(”=" + _workbook.Worksheets[0].Name + “!A1:F” + _workbook.Worksheets[0].Cells.Rows.Count, “B4”, “PivotTable1”);
Aspose.Cells.Pivot.PivotTable pivotTable = pivotTables[index];

pivotTable.RowGrand = true;
pivotTable.IsAutoFormat = true;
pivotTable.AutoFormatType = Aspose.Cells.Pivot.PivotTableAutoFormatType.Table1;
pivotTable.AddFieldToArea(Aspose.Cells.Pivot.PivotFieldType.Row, “Branch”);
pivotTable.AddFieldToArea(Aspose.Cells.Pivot.PivotFieldType.Row, “MO”);
pivotTable.AddFieldToArea(Aspose.Cells.Pivot.PivotFieldType.Row, “Source”);

//Dragging Fields to Data Area

PivotField nominal = pivotTable.BaseFields[“Outstanding”];
nominal.Function = ConsolidationFunction.Sum;
nominal.NumberFormat = “#,##0.00”;
pivotTable.AddFieldToArea(PivotFieldType.Data, nominal);

PivotField payment = pivotTable.BaseFields[“Current”];
payment.Function = ConsolidationFunction.Sum;
payment.NumberFormat = “#,##0.00”;
pivotTable.AddFieldToArea(PivotFieldType.Data, payment);

PivotField pctg = pivotTable.BaseFields[“Overdue”];
pctg.NumberFormat = “#,##0.00”;
pivotTable.AddFieldToArea(PivotFieldType.Data, pctg);

if (pivotTable.DataField != null)
{
pivotTable.AddFieldToArea(PivotFieldType.Column, pivotTable.DataField);
}

pivotTable.DataFields[0].NumberFormat = “#,##0.00”;
pivotTable.DataFields[1].NumberFormat = “#,##0.00”;
pivotTable.DataFields[2].NumberFormat = “#,##0.00”;

index = _workbook.Styles.Add();
Style style = _workbook.Styles[index];
style.HorizontalAlignment = TextAlignmentType.Right;
CellArea area = pivotTable.RowRange;
int start = area.StartRow;
for (int i = pivotTable.RowRange.StartRow; i <= pivotTable.RowRange.EndRow; i++)
{
pivotTable.Format(i, 4, style);
pivotTable.Format(i, 5, style);
pivotTable.Format(i, 6, style);
}

PivotFieldCollection dfs = pivotTable.DataFields;
PivotField df = dfs[0];
df.IsAutoSort = true;
df.IsAscendShow = false;
// df.IsAscendSort = false;
df.AutoSortField = -1;
df.IsAutoShow = true;

// Final

sheet2.AutoFitColumns();
sheet2.MoveTo(0);

_xls = clsMain.getRandomFileName("Profit Comm ", “xls”);

if (clsMain.isFileExists(@_xls))
clsMain.fileDelete(@_xls);

_workbook.Save(@_xls);
}
catch { }
finally { }
}

Hi Winanjaya,


Thank you for contacting Aspose support.

Your code snippet to create the PivotTable on existing spreadsheet seems to be fine, therefore it should produce desired results. Although when we evaluated the presented scenario on our end while using the latest version of Aspose.Cells for .NET 8.0.2, we have noticed that the resultant spreadsheet causes MS Excel application to pop-up the message “Unable to read file”. Upon recovery, the MS Excel removed the PivotTable from the spreadsheet. We have logged this problem in our bug tracking system under ticket Id CELLSNET-42663 for further investigation & correction purposes. Please spare us little time to properly analyze the problem cause on our end. In the meanwhile, we will keep you posted with updates in this regard.

Please note, we have used the createPivot_MO method from your provided code snippet to create the PivotTable on the “Raw Data” in your provided spreadsheet. Doing so enabled us to replicate the problem as stated in the post title. Moreover, if we execute the provided code snippet as it is, it will create an empty PivotTable that isn’t allowed by MS Excel specification.

Hi Winanjaya,

Thanks for your using Aspose.Cells.

Please download and try the latest fix: Aspose.Cells for .NET v8.0.2.3 and let us know your feedback.

The issues you have found earlier (filed as CELLSNET-42663) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.