Copy Paste Sheet to Excel and Decimal Separator

Community Driven Extensions Project
Post Reply
emcube
Posts: 10
Joined: 29 Nov 2013, 13:37

24 Mar 2021, 12:32

I'm trying to use pe:sheet and testing functionalities, but when I copy/paste numeric cells to excel it results that decimal separatore is "." (dot) instead of "," (comma)
And of course I need comma as separator as I'm in Italy...
it shows correctly (eg. 123.456,78) in cells content but not when copying/pasting to excel

The same appens in https://www.primefaces.org/showcase-ext ... cUsage.jsf

I tryed also to set locale "de-DE" in pe:sheet and also "de-DE" in pe:column like this:

Code: Select all

			<pe:sheet id="sheet" widgetVar="sheetWidget" value="#{configuratorePostformatoHome.instance.righeMisureRichieste}" var="row"
		              height="625" rowKey="#{row.riga}" fixedCols="2" showRowHeaders="true"
		              resizableCols="true" resizableRows="true" filteredValue="#{configuratorePostformatoHome.righeMisureFiltered}"
		              sortBy="#{row.riga}" sortOrder="ascending" readOnly="false"
		              locale="de-DE" >
		              ...... 
			      <pe:sheetcolumn headerText="Prof" value="#{row.aNumber}" colWidth="50"
			                        styleClass="htRight"
			                        colType="numeric" 
			                        numericLocale="de-DE"
			                        numericPattern="#,##0.0"
			                        required="true"
			                        requiredMessage="Missing Number!">
			            <f:converter converterId="javax.faces.BigDecimal"/>
			          </pe:sheetcolumn>
			</pe:sheet>
Any suggestion?


Using JSF 2.2, Primefaces 6.2.17, Primefaces Extensions 6.2.10
Java EE Developing, Primefaces 6.2.17, PrimeFaces Extensions 6.2.10, Mojarra 2.2.12, Wildfly 9.0.2.final, CDI 1.2

Melloware
Posts: 3716
Joined: 22 Apr 2013, 15:48

24 Mar 2021, 13:38

It looks like its a problem with the underlying HandsonTable JS component the Sheet is based on.

See: https://github.com/handsontable/handson ... ssues/2102

Also: https://stackoverflow.com/questions/359 ... eric-value
PrimeFaces Developer | PrimeFaces Extensions Developer
GitHub Profile: https://github.com/melloware
PrimeFaces Elite 13.0.0 / PF Extensions 13.0.0
PrimeReact 9.6.1

emcube
Posts: 10
Joined: 29 Nov 2013, 13:37

25 Mar 2021, 12:28

It's a similar problem, because in that case the separator was missing, in my case there is a separator but it is wrong for my locale: dot instead of comma.

I've also tried to use a converter and seen that it is not called "getAsString" beacuse of this String.valueOf(item) that means "...toString" inside SheetRenderer (see below)

Thus, is there any work around I can use?
thanks

Code: Select all

private void encodeSelectItems(final SheetColumn column, final JavascriptVarBuilder options) {
        final JavascriptVarBuilder items = new JavascriptVarBuilder(null, false);
        final Object value = column.getSelectItems();
        if (value == null) {
            return;
        }
        if (value.getClass().isArray()) {
            for (int j = 0; j < Array.getLength(value); j++) {
                final Object item = Array.get(value, j);
                items.appendArrayValue(String.valueOf(item), true);
            }
        }
        else if (value instanceof Collection) {
            final Collection collection = (Collection) value;
            for (final Iterator it = collection.iterator(); it.hasNext();) {
                final Object item = it.next();
                items.appendArrayValue(String.valueOf(item), true);
            }
        }
        else if (value instanceof Map) {
            final Map map = (Map) value;

            for (final Iterator it = map.keySet().iterator(); it.hasNext();) {
                final Object item = it.next();
                items.appendArrayValue(String.valueOf(item), true);
            }
        }

        options.appendProperty("source", items.closeVar().toString(), false);
    }
Java EE Developing, Primefaces 6.2.17, PrimeFaces Extensions 6.2.10, Mojarra 2.2.12, Wildfly 9.0.2.final, CDI 1.2

Melloware
Posts: 3716
Joined: 22 Apr 2013, 15:48

25 Mar 2021, 13:34

Ahhh I think I need to fix that to use Converters on SelectItems.

I think the only way you could fix it is to override the Renderer method and add your Renderer to faces-config.xml.
PrimeFaces Developer | PrimeFaces Extensions Developer
GitHub Profile: https://github.com/melloware
PrimeFaces Elite 13.0.0 / PF Extensions 13.0.0
PrimeReact 9.6.1

emcube
Posts: 10
Joined: 29 Nov 2013, 13:37

25 Mar 2021, 15:28

Ok, thanks.

Have you got any suggestion for the problem of copy/paste to excel? I've looked inside the JS script but it is a mess...
If you, by the way, have ever seen the method/function in Hansontable that does the "textify" of a range, please tell me :)

many thanks
Java EE Developing, Primefaces 6.2.17, PrimeFaces Extensions 6.2.10, Mojarra 2.2.12, Wildfly 9.0.2.final, CDI 1.2

Melloware
Posts: 3716
Joined: 22 Apr 2013, 15:48

25 Mar 2021, 15:40

The only JS hack I have seen is this one..

https://stackoverflow.com/a/35963905/502366
PrimeFaces Developer | PrimeFaces Extensions Developer
GitHub Profile: https://github.com/melloware
PrimeFaces Elite 13.0.0 / PF Extensions 13.0.0
PrimeReact 9.6.1

Post Reply

Return to “Extensions”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 3 guests