Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I am creating a custom print function for our Sharepoint data as we have some requirements about the way the data is formatted and some of this depends on the content. I am using xml and xsl for this as we are not really allowed to use xslt dataview webparts. I have most of this working but I really miss the ddwrt:FormatDate and FormatDateTime functions. I thought I could just include the namespace in my stylesheet but this does not seem to work. I was hoping to find the code of that namespace, but I can not locate that anywhere. I need a way to duplicate that functionality.

share|improve this question
    
What are you using instead of the data view web parts? –  Alex Angas Jul 1 '10 at 3:15
    
I was actually referring to standard list views on the screen. I have built a javascript function that uses the webservice to get a copy of that view returned as XML and then I use xsl to format the data for Excel. This is an intranet so I save the xml file and then automate Excel to open and then print this file. It works just the way I need it to and Excel formats the date for me so I do not have to worry about that now. –  spevilgenius Jul 1 '10 at 13:56
add comment

2 Answers 2

Daniel:

Man, your hands are just always tied. Do the powers that be realize that, by forcing you around different ways, they are getting less standard (and supportable) solutions?

I believe that the ddwrt namespace functions are embedded in some of the Microsoft.SharePoint assemblies, so you can't use them easily outside of the SharePoint context.

However, check out http://www.exslt.org/. I've looked at it in the past, and there seem to be some great capabilities there. I'm not sure how you implement it frankly, but you probably can figure it out.

M.

share|improve this answer
    
I've tried to use EXSLT before with SharePoint but because it needs JavaScript to work, it's not usually an option. –  Alex Angas Jul 1 '10 at 3:16
    
Alex: Not sure I understand your comment. Don't we always need JavaScript for SharePoint to function properly? –  Marc D Anderson Jul 6 '10 at 11:49
add comment

I used reflector to copy the ddwruntime into my own class. I had to comment out some functions. Once that was done, I was able to do my own xslt transform using some code similar to this:

XsltArgumentList xslArgs = new XsltArgumentList();
DdwRuntime runtime = new DdwRuntime();
runtime.View = view;
runtime.List = list;
runtime.Web = web;
runtime.ListItem = listItem;          
xslArgs.AddExtensionObject("http://schemas.microsoft.com/WebParts/v2/DataView/runtime", runtime);

XslCompiledTransform transform = new XslCompiledTransform(true);
transform.Load(xsltcontent);

using (StringWriter writer = new StringWriter())
{
    transform.Transform(content, xslArgs, writer);
    return writer.ToString();
}

I've had great success taking xslt from sharepoint designer and using them in my custom webpart using this method.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.