Using the pound (£) symbol to format cells as currency

Topics: Developer Forum
Nov 18, 2010 at 3:17 PM
Edited Nov 18, 2010 at 3:19 PM

Hi there,

I have a client that is looking to export some figures from their database into an Excel sheet. This involves the pound symbol (£) as their business is in the UK. I've tried using the following code:

 


$currencyFormat = '[$£-809]#.##0,00;[Red]-[$£-809]#.##0,00';

$objPHPExcel->getActiveSheet(0)->getStyle('G5:G6')->getNumberFormat()->setFormatCode($currencyFormat);

 

However this pulls up errors and won't create the sheet correctly. When I open the sheet, I get the error:

"Excel ha encontrado contenido que no se puede leer en 'text.xlsx'. ¿Desea recuperar el contenido del libro? Si confia en el origen de este libro, haga clic en Si."

or in English;

"Excel has found content that can not be read in 'text.xlsx'. Do you want to retrieve the contents of the book? If you trust the source of this workbook, click Yes."

If I click Si/Yes, then it opens the workbook but with no formatting at all.

Does anyone have any ideas or suggestions?

 

My version numbers are:

PHPExcel: Version 1.7.4, 2010-08-26

PHP Version: 5.2.14

Running on Linux.

Thanks,

Stu

Nov 18, 2010 at 3:25 PM

Quick update;

 

The error I'm getting is:

"Carácter xml no válido"

or in English;

"XML character not valid"

So for some reason it doesn't like the pound symbol at all. Is there a way to put in the ASCII code for the pound symbol rather than the symbol itself?

Coordinator
Nov 18, 2010 at 10:01 PM

Ensure that you're using the UTF-8 codepoint for £ rather than the ISO-8859-1 codepoint

Sep 8, 2011 at 10:58 AM

I have the same problem with formatting the pound sign. Try the formatting above but the writer throw exception about the iconv detect illegal character.

 

When I try to just use =CHAR(163) the output is just the symbol you get when an unknown character has been input.

 

I have check the formatting and its indeed in UTF-8. So any idea how to fix this? 

 

Thank you very much

Jan 5, 2012 at 4:19 AM

how to export the pound symbol while exporting the data to phpexcel... pls help me