This project has moved and is read-only. For the latest updates, please go here.

Cell's stylename

Jun 28, 2011 at 4:23 PM


I read an xlsm file using EPPlus. I am positively-sure-and-certain that a particular cell has style which is named "Base". Hence, I don't understand why the StyleName's property is "Normal".

Thank's for your help,


Jun 29, 2011 at 6:49 PM

Ok, I have the feeling nobody believes me. If so, try this :

  • Open a new excel document
  • Select cell "A1"
  • Set style "Title 1"
  • Save and quit Excel
  • Run the following program :
class MyTest
	public static void Run(string FilePath)
		FileInfo existingFile = new FileInfo(FilePath);
		ExcelPackage package = new ExcelPackage(existingFile);
		ExcelWorksheet worksheet = package.Workbook.Worksheets[1];
		ExcelRange cell = worksheet.Cells[1, 1];
You will get "Normal" as the unwanted result.
Any help will be geatly appreciated,
Jun 30, 2011 at 6:52 PM

Humm, I think it is a bug too, but StyleId property looks can do a workaround, if you want to get stylename, do this:

        static void Main(string[] args)
            FileStream ff = new FileStream("a.xlsx", FileMode.Open);
            ExcelPackage p = new ExcelPackage(ff);

            var ws = p.Workbook.Worksheets[1];
            var cell = ws.Cells[1,1];



Jun 30, 2011 at 8:02 PM
Edited Jun 30, 2011 at 8:03 PM

Hehe, I believe you, this is a bug. The style name is not reed from the template. I'll check in a fix tomorrow

Jul 1, 2011 at 5:47 PM
Edited Jul 1, 2011 at 5:50 PM

Hello all,

I tried the workarount but nnfotunately cell.StyleID is not "always" the namedStyle's index. Thanks anyway,


Jul 2, 2011 at 3:22 AM

Get the lastest version from trunk. Jan have already fixed this. 

Jul 4, 2011 at 1:38 PM

Thanks a lot, I'm dying to use it but can't open the trunk with my Visual Studio 2008 nor with Visual Studio 2010 Express. Can I get the dll ?


Jul 5, 2011 at 10:02 AM

Sorry for the previous post, I eventually understood that everything happens in 'ExcelPackage' project, which I compiled and it works fine with the sample workbook but not the workbook provided by the user. Actually, EPPLUS can't read worksheets, package.Workbook.worksheets.count = 0.

If you're intersted I can provide the workbook.



Jul 7, 2011 at 6:38 PM

Sorry, a thousand apologies for being dummy, I didn't read no file...

Anyway, cell.StyleName still returns "Normal" although it has a named style.

I tried UpdateXml (I read about in the source comments).



FileInfo existingFile = new FileInfo(FilePath); 
ExcelPackage package = new ExcelPackage(existingFile); 
ExcelWorksheet worksheet = package.Workbook.Worksheets[3]; 
ExcelRange cell = worksheet.Cells[4, 6];