|
Hi, I have a problem. I am trying to read a xls file. On my local machine everything works fine, but when i test it on a server i get this error "An item with the same key has already been added" on this line "book.Open(fileStream);"
I hope someone can help me, and sorry for my bad english :$
Here is the Stack Trace:
[ArgumentException: An item with the same key has already been added.]
System.ThrowHelper.ThrowArgumentException(ExceptionResource resource) +51
System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add) +2628449
System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value) +11
QiHe.Office.Excel.MsofbtDgg.Decode() in C:\DDisk\Harweb.net HWD\Dynamic Linked Libraries\Generales\System.Harweb.Utilidades\System.Harweb.Utilidades\ExcelReader\Office\Excel\Extended\MsofbtDgg.cs:25
QiHe.Office.Excel.MsofbtContainer.Decode() in C:\DDisk\Harweb.net HWD\Dynamic Linked Libraries\Generales\System.Harweb.Utilidades\System.Harweb.Utilidades\ExcelReader\Office\Excel\Extended\MsofbtContainer.cs:19
QiHe.Office.Excel.MSOCONTAINER.Decode() in C:\DDisk\Harweb.net HWD\Dynamic Linked Libraries\Generales\System.Harweb.Utilidades\System.Harweb.Utilidades\ExcelReader\Office\Excel\Extended\MSOCONTAINER.cs:19
QiHe.Office.Excel.Workbook.DecodeRecords() in C:\DDisk\Harweb.net HWD\Dynamic Linked Libraries\Generales\System.Harweb.Utilidades\System.Harweb.Utilidades\ExcelReader\Office\Excel\Workbook.cs:103
QiHe.Office.Excel.Workbook.Read(Stream stream) in C:\DDisk\Harweb.net HWD\Dynamic Linked Libraries\Generales\System.Harweb.Utilidades\System.Harweb.Utilidades\ExcelReader\Office\Excel\Workbook.cs:43
QiHe.Office.Excel.Workbook.Open(Stream file) in C:\DDisk\Harweb.net HWD\Dynamic Linked Libraries\Generales\System.Harweb.Utilidades\System.Harweb.Utilidades\ExcelReader\Office\Excel\Workbook.cs:37
System.Harweb.Utilidades.ClsFiles.GetExcelData(String filePath, String tableName) in C:\DDisk\Harweb.net HWD\Dynamic Linked Libraries\Generales\System.Harweb.Utilidades\System.Harweb.Utilidades\ClassFiles.cs:96
perfilxls.Page_Load(Object sender, EventArgs e) in c:\inetpub\wwwroot\Harweb_SESA\harweb\1131\mov\movlab\dinamico\cargar\perfilxls.aspx.cs:78
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +50
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627
|
|
|
|
|
Hi,
I have read in an existing spreadsheet and need to insert a column in postion 0 (first column).
Is there anyway to do this?
The method i tried just overwrites the read in data.
Thanks
Scott.
modified on Tuesday, August 25, 2009 9:58 AM
|
|
|
|
|
I couldnt find a way to do it so added this method to the row class:
public void InsertColumn(int colIndex, Cell cell)
{
for(int i=LastColIndex; i >= colIndex; i--)
{
Cell tempCel = GetCell(i);
SetCell(i + 1, tempCel);
}
SetCell(colIndex, cell);
}
Feel free to include this in the next release as i think its a needed feature.
Thanks
Scott
|
|
|
|
|
Hi
this is a great project, nice job Liu
but I have a little problem, when I modify a file and when I save it I lost all the formulas present in the file and in the cells where there were the formulas I found only the value, this is the code that I use:
Workbook book = Workbook.Open(txtSource.Text);
Worksheet sheet = book.Worksheets[0];
sheet.Cells[0, 0] = new Cell("Test");
book.Save(txtDestinazione.Text);
I wrong something or anything else?
Thanks
|
|
|
|
|
The code works as rewritting the whole file. Formatting styles, formulas and other unsupported features are not preserved.
I am happy to work with people doing great projects.
|
|
|
|
|
Hi Liu
Nice work on the library, I was wondering how do you create a hyperlink to a relative path in a cell.
Cheers Mick
|
|
|
|
|
|
Huh?? This libray does not use interop, ergo Excel is not required to be installed on the client machine.
|
|
|
|
|
Could anyone give me a little code-sample on how to get the markup for a cell (fonts, border, color etc).
I'm trying to get it running in ASP.NET (C#), but I cannot seem to get it right.
Thanks in advance,
K. van der Werf
|
|
|
|
|
I am also looking for a solution on how to do this.
|
|
|
|
|
I am new to the boards- but I don't see a solution for this. Is there any example or quick place in the documentation to see how to adjust the color, font etc. of a given cell? I see that it is in Format, but I don't seem to be doing something right.
thanks,
-scott
|
|
|
|
|
Exception of type 'System.OutOfMemoryException' was thrown.
at
this.MasterSectorAllocationTable = new List<int>(NumberOfSecIDs);
The number of sector IDs is 1836592733. Is that to big for an int?
Michael S. Flynn
|
|
|
|
|
I am writing an extra row to an existing Excle spreadsheet and after writing the file I try to reopen the file and receive an error:
EndOfStreamException was unhandeld
Unable to read beyond te end of the stream;
When I open the file in Excel and save it with Excel I am able to open it with my program again.
Any idea why this is happening?
|
|
|
|
|
Hello,
first thanks for a nice project.
What would be the easiest way to directly encode a Workbook object to the Output-stream of a Html webpage Response object without needing to first save the information to file.
E.g. The user uploads an Excel file with some information that is processed and added to by the server which than should return the information to the user by letting them decide where to save the new/modified file.
Any idea about the best/easiest way to accomplish this?
Best regards,
Henrik
|
|
|
|
|
Implemented by r47. You can use Workbook's Save(Stream stream) method.
I am happy to work with people doing great projects.
|
|
|
|
|
I am able to generate the excel with my Webpage using the following codes. The file download dialog will be shown and user can save the file on desktop.
When I open the file, it displays this message "Lost document summary information.". But the file appear correct as it contains all data and worksheets. Any idea what could be the reason? Being trying all ContentType, Response method, but none seems to be able to remove that error message.
Thanks.
Response.Clear();
Response.ContentType = "application/vnd.ms-excel";
Response.AddHeader("Content-Disposition", "attachment;filename=excelfile1.xls");
WorkbookEncoder.Encode(workbook, Response.OutputStream);
Response.End();
|
|
|
|
|
Hi, not sure if this is the best method I should be using.
I overload the 2 methods in your project to pass in MemoryStream and I am able to export excel with ease from my ASPX.
public static CompoundDocument Create(MemoryStream stream) - CompountDocument.cs
public MemoryStream SaveStream(MemoryStream streamInput) - Workbook.cs
Codes use in my ASPX page to generate the excel file on the fly.
Response.Clear();
Response.ContentType = "application/ms-excel";
Response.AddHeader("Content-Disposition", "attachment;filename=XLSFormat.xls");
MemoryStream streamOutput = new MemoryStream();
MemoryStream streamInput = new MemoryStream();
streamOutput = workbook.SaveStream(streamInput);
Response.OutputStream.Write(streamOutput.ToArray(), 0, streamOutput.ToArray().Length);
Response.Flush();
Response.Close();
Response.End();
|
|
|
|
|
maxnm,
Can you send the 2 overloaded methods on this thread.
thanks.
|
|
|
|
|
I'm also interested about trying overloaded Create() and SaveStream() methods. Where to find their source code ? Andrus
|
|
|
|
|
|
Document summary information is not encoded to the generated file. So the message "Lost document summary information." is right about this. But it depends on the Viewer/Editor to show this message or not. Of course we should better support encoding Document summary information.
I am happy to work with people doing great projects.
|
|
|
|
|
Hello,
with this Excel .NET component you can easily create and download Excel files from your Excel ASP.NET applications without using Excel Automation.
Here is a sample Excel C# code how to export DataSet as XLS stream:
var ef = new ExcelFile();
foreach (var dataTable in dataSet.Tables)
{
var ws = ef.Worksheets.Add(dataTable.TableName);
ws.InsertDataTable(dataTable, "A1", true);
}
Response.Clear();
Response.ContentType = "application/vnd.ms-excel";
Response.AddHeader("Content-Disposition", "attachment; filename=Employee.xls");
ef.SaveXls(Response.OutputStream);
Response.End();
|
|
|
|
|
Hi,
really great job, tnx.
In my program I read Excel by one row at a time.
How can I know when I reached the last row ?
Respectfully,
Exceter.
|
|
|
|
|
int row = 0;
int col = 0;
while (sheet.Cells[row, col].StringValue != "")
{
lv.Items.Add(sheet.Cells[row, col].StringValue);
col++;
}
|
|
|
|
|
worksheet.Cells.LastRowIndex
I am happy to work with people doing great projects.
|
|
|
|