Error Message in Excel.Save() method

When I use Aspose.Excel to save my modified excel file, it throw an exception:

[NullReferenceException] 
Aspose.Excel.Record.c5.a(c3 A_0, t A_1, Worksheets A_2)
Aspose.Excel.Worksheets.a(String A_0, SaveType A_1, FileFormatType A_2, HttpResponse A_3)


[Exception: Errors in Excel Save method]
Aspose.Excel.Worksheets.a(UInt32 A_0, Exception A_1)
Aspose.Excel.Worksheets.a(String A_0, SaveType A_1, FileFormatType A_2, HttpResponse A_3)
Aspose.Excel.Excel.Save(String resultSpreadsheet, FileFormatType fileFormatType)
Aspose.Excel.Excel.Save(String resultSpreadsheet) …




I find a message “Access denied because you do not have enough permissions, or another user has the file open and locked.“
But … I never open that report file, file permission is “Everyone”.
How can I resolve this problem?




My Code is following…
public override string GenerateReport(DataTable Source)
{
Hashtable htIndex = this.GetReportCellIndex(this.g_Index);
int CurrentRowIndex = this.g_Index;
string strTempReportFileName = Guid.NewGuid().ToString();
   foreach (DataRow row in Source.Rows)
{
this.g_xls.Worksheets[“Rework”].Cells.InsertRow(CurrentRowIndex);
// navigate columns and process data fill operation.
foreach (DataColumn column in Source.Columns)
{
// get cell’s row and column index.
if (htIndex.ContainsKey(column.ColumnName))
{
if (row[column.ColumnName].ToString() != String.Empty)
this.g_xls.Worksheets[“Rework”].Cells[htIndex[column.ColumnName].ToString()].PutValue(row[column.ColumnName]);
else
this.g_xls.Worksheets[“Rework”].Cells[htIndex[column.ColumnName].ToString()].PutValue(String.Empty);
}
}
    CurrentRowIndex++;
}
   this.g_xls.Save(String.Format(”{0}\{1}.xls”, this.g_strTempFilePath, strTempReportFileName));

return String.Format("{0}.xls", strTempReportFileName);
}



Thanks a lot!!

Is your application a web app? If yes, please change your code from

this.g_xls.Save(String.Format("{0}\{1}.xls", this.g_strTempFilePath, strTempReportFileName));

to

this.g_xls.Save(“book1.xls”, SaveType.OpenInExcel, FileFormatType.Default, this.Response);

That can test if your program has the permission to access the directory. You should make the directory permission to read/write for your application.