Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Kristoffer Eriksen 185 posts 465 karma points
    Aug 08, 2012 @ 11:37
    Kristoffer Eriksen
    0

    Create custom XLS when exporting

    Is it possible... oh sorry... everything is possible... but is it somewhat straighforward to change the exported XLS layout, when saving for xls.

    The customer wants the informationer for each entry to be listed vertically.

    So the info from entry #1 is in column A, info from entry #2 is in column B etc...

  • Comment author was deleted

    Aug 08, 2012 @ 11:42

    Hey Kristoffer,

    You could update the ~\umbraco\plugins\umbracoContour\xslt\excel.xslt file, that is responsable for the excel export of course if you then upgrade Contour it will overwrite your changes so if you are up for it you can also create your own custom export type using the provider model :)  Details can be found in the contour developer docs on the contour project page (http://our.umbraco.org/projects/umbraco-pro/contour) but you'll just need a custom xslt file and a class for your provider that looks like

        public class ExportToExcel : ExportType {
    
            public ExportToExcel() {
                this.Description = "Exports all data to a csv file";
                this.Name = "CSV File";
                this.Id = new Guid("94ED105A-87B3-4e1f-97CB-9A320AEE2745");
                this.FileExtension = "csv";
            }
    
            private string xslt = Configuration.Path + "/xslt/excel.xslt";
    
            public override string ExportForm(Form form)
            {
                RecordsViewer rv = new RecordsViewer();
                XmlDocument xs = new XmlDocument();
                XmlNode XmlRecords = rv.GetXmlRecords(form, xs);
                rv.Dispose();
    
                return XsltConvert(XmlRecords, HttpContext.Current.Server.MapPath(xslt));
            }
        }
  • Kristoffer Eriksen 185 posts 465 karma points
    Aug 08, 2012 @ 11:56
    Kristoffer Eriksen
    0

    Hey Tim

    Perfect. I just didn't know where to look.

    I may have found another solution, which is even more simple.The customer wouldn't mind to get the information each time a new entry was submitted, so my suggestion to them, was to create a new workflowentry, which would send them a XSLT formatted email, with just the informations they need, in the layout they want it.

    They are just interested in 4-5 columns out of the entire 40 column form, which then should be copy/pasted to a word-document.

    So that might be the way we solve this issue.

    But I will definitely look into the providermodel.

  • Comment author was deleted

    Aug 08, 2012 @ 13:37

    Yup that would also work, glad I could help!

  • Dan White 206 posts 510 karma points c-trib
    Nov 26, 2013 @ 23:31
    Dan White
    0

    @Tim

    I'm trying to create a custom export that lets the user choose the status of the records they want. It keeps exporting all records no matter what the user picks though. In debugging I can see that List<Umbraco.Forms.Core.Enums.FormState> States has the correct value, so that's not it. 

    public class VerticalHtmlTable : ExportType
        {
            [Umbraco.Forms.Core.Attributes.Setting("Export _X_ Records",
                description = "Only exports records of the selected status.",
                control = "Umbraco.Forms.Core.FieldSetting.Dropdownlist",
                prevalues = "Approved, Submitted, Partially Submitted, All")]
            public string recordStatus { get; set; }        
    
            public VerticalHtmlTable()
            {
                this.Description = "Exports all data to a vertical HTML table. Ideal for large forms.";
                this.Name = "Vertical HTML Table";
                this.Id = new Guid("BB0E1863-F963-4B8D-B028-94494844D901");
                this.FileExtension = "html";
            }
    
            private string xslt = Configuration.Path + "/xslt/verticalHtmlTable.xslt";
    
            public override string ExportForm(Form form)
            {
                List<Umbraco.Forms.Core.Enums.FormState> States = GetRecordStates();
    
                RecordsViewer rv = new RecordsViewer();
                XmlDocument xs = new XmlDocument();
                XmlNode XmlRecords;
    
                if (States.Any())
                {
                    XmlRecords = rv.GetXmlRecords(form, 0, States, xs);                
                }
                else
                {
                    XmlRecords = rv.GetXmlRecords(form, xs);
                }
    
                rv.Dispose();
    
                return XsltConvert(XmlRecords, HttpContext.Current.Server.MapPath(xslt));
            }
    
            private List<Umbraco.Forms.Core.Enums.FormState> GetRecordStates()
            {
                List<Umbraco.Forms.Core.Enums.FormState> states = new List<Umbraco.Forms.Core.Enums.FormState>();
                states.Clear();
                switch(recordStatus.Trim()){
                    case "Approved":
                        states.Add(Umbraco.Forms.Core.Enums.FormState.Approved);
                        break;
                    case "Submitted":
                        states.Add(Umbraco.Forms.Core.Enums.FormState.Submitted);
                        break;
                    case "Partially Submitted":
                        states.Add(Umbraco.Forms.Core.Enums.FormState.PartiallySubmitted);
                        break;
                }
    
                return states;
            }
        }
Please Sign in or register to post replies

Write your reply to:

Draft