- Home
- Forum
- ASP.NET MVC
- Worksheet Excel, check for existence and add new values at the end of that worksheet
Worksheet Excel, check for existence and add new values at the end of that worksheet
I Need something like this:
//1. Check if a worktsheet("((IWorksheet)workbook.worksheet[x]).Name)") exist
//1a) if true
-> Add at the last position( two values(2 cells, 2 different contents)(worksheet.UsedRange.LastRow ?!) for that existing sheet
//1b)if false
-> Create a new empty worksheet
-> Add at the last position two values(2 cells, 2 different contents) (worksheet.UsedRange.LastRow ?!)for that new sheet
How to build this ?!
//1. Check if a worktsheet("((IWorksheet)workbook.worksheet[x]).Name)") exist
//1a) if true
-> Add at the last position( two values(2 cells, 2 different contents)(worksheet.UsedRange.LastRow ?!) for that existing sheet
//1b)if false
-> Create a new empty worksheet
-> Add at the last position two values(2 cells, 2 different contents) (worksheet.UsedRange.LastRow ?!)for that new sheet
How to build this ?!
SIGN IN To post a reply.
6 Replies
SR
Sudha Ramachandran
Syncfusion Team
December 12, 2016 10:49 AM UTC
Hi,
We have provided a simple sample based on you scenario in the below link. Please try the sample and let us know if this helps.
Regards,
Sudha R
TE
Testname
December 12, 2016 12:48 PM UTC
TE
Testname
December 12, 2016 02:48 PM UTC
Ok, I solved the above mentioned issue, but I think I found a bug ?!
Running the same logic over:
string name="00_XXXXXXXXXXXXXXXXXX_XXX_XXX_XXX";
if (workbook.Worksheets[name] != null)
{
sheet = workbook.Worksheets[name];
}
else
{
sheet = workbook.Worksheets.Create(name);
}
over again will result in wrong results:
One time the tab name in Excel will be e.g:
"00_XXXXXXXXXXXXXXXXXX"
"00_XXXXXXXXXXXXXXXXXX_XXX_X"
"00_XXXXXXXXXXXXXXXXXX_XXX_XXX_X"
Maybe the length of the tab name depends on all elements in "workbook.Worksheets".
The problem here is if I read in the same file again, syncfusion will create a new sheet "workbook.Worksheets.Create(name)", because the library thinks the tab does not exist.
Actually this is true, because the string ("name") will be shortend, but actually it is always the same string.
What to do here ?!
Running the same logic over:
string name="00_XXXXXXXXXXXXXXXXXX_XXX_XXX_XXX";
if (workbook.Worksheets[name] != null)
{
sheet = workbook.Worksheets[name];
}
else
{
sheet = workbook.Worksheets.Create(name);
}
over again will result in wrong results:
One time the tab name in Excel will be e.g:
"00_XXXXXXXXXXXXXXXXXX"
"00_XXXXXXXXXXXXXXXXXX_XXX_X"
"00_XXXXXXXXXXXXXXXXXX_XXX_XXX_X"
Maybe the length of the tab name depends on all elements in "workbook.Worksheets".
The problem here is if I read in the same file again, syncfusion will create a new sheet "workbook.Worksheets.Create(name)", because the library thinks the tab does not exist.
Actually this is true, because the string ("name") will be shortend, but actually it is always the same string.
What to do here ?!
SS
Sridhar Sukumar
Syncfusion Team
December 13, 2016 12:54 PM UTC
Hi,
|
Query |
Response | |
|
The problem here is if I read in the same file again, syncfusion will create a new sheet "workbook.Worksheets.Create(name)", because the library thinks the tab does not exist. Actually this is true, because the string ("name") will be shortend, but actually it is always the same string.
What to do here ?! |
We can reproduce the issue. A support incident to track the status of this incident has been created under your account. Please log on to our support website to check for further updates.
| |
|
The more data I the more the cells get shifted. attachment |
The column can be re-located using the below code.
Please refer the following code snippet in your sample to achieve this
Code snippet:
|
Please let me know if you have any questions.
Regards,
Sridhar S
MV
mvxyc
December 13, 2016 01:16 PM UTC
thanks :)
RP
Ranjani Prabhakaran
Syncfusion Team
December 14, 2016 05:26 AM UTC
Dear Customer,
Thank for the update. Please do reach us if you need any assistance in future.
Regards,
SIGN IN To post a reply.
- 6 Replies
- 5 Participants
-
TE Testname
- Dec 9, 2016 12:10 PM UTC
- Dec 14, 2016 05:26 AM UTC