Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

  • exportClientData and Hilite result in <span> markup in exported XLSX file

    Hi Isomorphic,

    please see this testcase (created using SNAPSHOT_v11.1d_2017-04-13, but happens also in my application using latest 5.1p).

    When you open the exported XLSX (I used LibreOffice 5.3.2) you'll see that the cells contain <span>-markup.
    (For a test, I also changed the job-field to escapeHTML="true" in employees.ds.xml, but this did not change anything, either.)

    Code:
    package com.smartgwt.sample.client;
    
    import com.google.gwt.core.client.EntryPoint;
    import com.smartgwt.client.Version;
    import com.smartgwt.client.core.KeyIdentifier;
    import com.smartgwt.client.data.AdvancedCriteria;
    import com.smartgwt.client.data.Criterion;
    import com.smartgwt.client.data.DSRequest;
    import com.smartgwt.client.data.DataSource;
    import com.smartgwt.client.data.Hilite;
    import com.smartgwt.client.data.SortSpecifier;
    import com.smartgwt.client.types.ExportFormat;
    import com.smartgwt.client.types.OperatorId;
    import com.smartgwt.client.types.SortDirection;
    import com.smartgwt.client.util.Page;
    import com.smartgwt.client.util.PageKeyHandler;
    import com.smartgwt.client.util.SC;
    import com.smartgwt.client.widgets.IButton;
    import com.smartgwt.client.widgets.Window;
    import com.smartgwt.client.widgets.events.ClickEvent;
    import com.smartgwt.client.widgets.events.ClickHandler;
    import com.smartgwt.client.widgets.form.fields.ComboBoxItem;
    import com.smartgwt.client.widgets.grid.ListGrid;
    import com.smartgwt.client.widgets.grid.ListGridField;
    import com.smartgwt.client.widgets.layout.VLayout;
    
    public class BuiltInDS implements EntryPoint {
        private VLayout mainLayout;
        private IButton recreateBtn;
    
        public void onModuleLoad() {
            KeyIdentifier debugKey = new KeyIdentifier();
            debugKey.setCtrlKey(true);
            debugKey.setKeyName("D");
    
            Page.registerKey(debugKey, new PageKeyHandler() {
                public void execute(String keyName) {
                    SC.showConsole();
                }
            });
    
            mainLayout = new VLayout(20);
            mainLayout.setWidth100();
            mainLayout.setHeight100();
    
            recreateBtn = new IButton("Recreate");
            recreateBtn.addClickHandler(new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                    recreate();
                }
            });
            mainLayout.addMember(recreateBtn);
            recreate();
            mainLayout.draw();
        }
    
        private void recreate() {
            Window w = new Window();
            w.setWidth("95%");
            w.setHeight("95%");
            w.setMembersMargin(0);
            w.setModalMaskOpacity(70);
            w.setTitle(" (" + Version.getVersion() + "/" + Version.getSCVersionNumber() + ")");
            w.setTitle("Export has visible tags in data when using Hiliting" + w.getTitle());
            w.setShowMinimizeButton(false);
            w.setIsModal(true);
            w.setShowModalMask(true);
            w.centerInPage();
    
            final ListGrid employeesGrid = new ListGrid();
    
            employeesGrid.setHeight100();
            employeesGrid.setAutoFetchData(false);
            employeesGrid.setCanEdit(true);
            employeesGrid.setDataSource(DataSource.get("employees"));
    
            ListGridField employeeId = new ListGridField("EmployeeId");
    
            ListGridField name = new ListGridField("Name");
    
            ListGridField gender = new ListGridField("Gender");
    
            ListGridField reportsTo = new ListGridFieldReportsTo("ReportsTo");
    
            ListGridField job = new ListGridField("Job");
    
            employeesGrid.setFields(employeeId, name, gender, reportsTo, job);
            employeesGrid.setSort(new SortSpecifier[] { new SortSpecifier(name.getName(), SortDirection.ASCENDING) });
    
            Hilite redHitlite = new Hilite() {
                {
                    setTextColor("red");
                    setCriteria(new AdvancedCriteria(new Criterion("Name", OperatorId.STARTS_WITH, "Ab")));
                }
            };
            employeesGrid.setHilites(new Hilite[] { redHitlite });
    
            w.addItem(employeesGrid);
    
            IButton expButton = new IButton("Export", new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                    DSRequest exportRequest = new DSRequest();
                    exportRequest.setExportAs(ExportFormat.OOXML);
                    employeesGrid.exportClientData(exportRequest);
                }
            });
            w.addItem(expButton);
            employeesGrid.fetchData(new AdvancedCriteria(new Criterion(name.getName(), OperatorId.STARTS_WITH, "A")));
            w.show();
        }
    
        private class ListGridFieldReportsTo extends ListGridField {
            public ListGridFieldReportsTo(String name) {
                super(name);
                ComboBoxItem managerCBI = new ComboBoxItem();
                managerCBI.setOptionDataSource(DataSource.get("employees"));
                managerCBI.setValueField(DataSource.get("employees").getPrimaryKeyFieldName());
                managerCBI.setDisplayField("Name");
                managerCBI.setPickListSort(new SortSpecifier[] { new SortSpecifier("EmployeeId", SortDirection.ASCENDING),
                        new SortSpecifier("Name", SortDirection.ASCENDING) });
                ListGridField managerCBI_empIdLGF = new ListGridField("EmployeeId");
                ListGridField managerCBI_nameLGF = new ListGridField("Name");
                managerCBI.setPickListFields(managerCBI_empIdLGF, managerCBI_nameLGF);
                managerCBI.setPickListHeaderHeight(0);
                setEditorProperties(managerCBI);
            }
        }
    }
    SpanMarkup.PNG

    Best regards
    Blama

  • #2
    This is fixed and will be available for download in nightly builds since Apr 18 (tomorrow). Thanks for the report.

    Comment


    • #3
      Hi Isomorphic,

      using SNAPSHOT_v11.1d_2017-04-18 this is fixed for me in the testcase above. It is not fixed if you set escapeHTML="true" for the type="text"-fields in the employees.ds.xml.

      Best regards
      Blama

      Comment


      • #4
        This is fixed and will be available for download in nightly builds since Apr 30 (tomorrow). Thanks for the report.

        Comment

        Working...
        X