We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Aspose.Cells ignore column name defined in Excel 2010 using name manager and give name default value

Steps to reproduce:

  1. Create XLSX file and add some random cell values into first column in first 4 rows
  2. Define name for cell “A3”, TotalRevenue using either DefineNames or Name Manager
  3. Add this excel file into project and embedded it into dll/exe using “EmbeddedResource” on Properties tab of the Visual Studio
  4. Using Assembly.GetExecutingAssembly().GetManifestResourceStream("…") get stream
  5. Access cell name using following syntax:

    Stream demoFile = Assembly.GetExecutingAssembly().GetManifestResourceStream(“ConsoleApplication3.Demo.xlsx”);
    Workbook excelFile = new Workbook(demoFile);
    excelFile.Worksheets[1].Cells[“TotalRevenue”].Value = “10”;

  6. Exception has been thrown "Invalid cell name"

Expected behavior:

We should be able to access named cell using define name.

Note:
  • Cell is accessible using default cell name: excelFile.Worksheets[1].Cells[“A3”]
  • When file is saved, resulting file contains name defined for cell A3

Technical info:

Excel 2010
Aspose.Cells v. 7.5.1.0
Framework: .NET 4.0
Visual Studio 2012
Windows 7

Best regards,
Goran

Hi,

Thanks for your posting and using Aspose.Cells for .NET.

Please use the following code to access the defined name and change its value. We have tested it with the latest version: Aspose.Cells
for .NET v7.5.1.1
and it is working fine.

C#


string filePath = @“F:\Shak-Data-RW\Downloads\Book.xlsx”;


Workbook workbook = new Workbook(filePath);


Range range = workbook.Worksheets.GetRangeByName(“Total”);

range.Value = “10”;


workbook.Save(filePath + “.out.xlsx”);

Hi,


thank You for quick reply.

I confirmed that suggestion works.

I have additional question.

Since cell name is not unique across worksheets, can I get same result for specific worksheet or suggestion is that I create unique names across all worksheets?

Best regards,
Goran

Hi,

Thanks for your posting and using Aspose.Cells.

Well, if cell name is not unique across the worksheets, I think, you should not have any problem. The code should work fine. Let us know if you face any issues, we will look into it and update you asap.