Showing posts with label xml. Show all posts
Showing posts with label xml. Show all posts

Saturday, June 7, 2014

Jquery shake effect - part 2

Hurrey 100th post , and again on Jquery :)


Jquery shake effect is very popular & more searchable topic now a days.

Long back i had written a post on jquery shake effect. this is my part 2 post where here I'm going to explain what all method and what option you may find in
JRumble plugin
 
You must have seen that vibrant, rotate, shake and many other elements of effects. using css and other scripting language you can create more eye catch able effects.

JRumble is new plugin which has more elements on effects. it also a good plugin with hover and direction effect.

Below are few objects


  $('imgName').jrumble();
  // you may stop the elements like this way
  $('imgName').trigger('stopRumble');


You many even customize this options with below attributes:


Rotation : set the range , default is 1


Speed : set  frequency or speed between the two movements


X : set horizontal pixels


Y : set vertical pixels


and there are many other elements. 


The below code shows the example along with basic functionality.




$(document).ready(function() {
    $('ImageName').jrumble({
        y:4,
        x:3,
        rotation: 10,
    speed:500,
    opacity:100
    });

    $('ImageName').hover(function() {
        $(this).trigger('startRumble');
    }, function() {
        $(this).trigger('stopRumble');
    });
});​



See the below example :


Saturday, November 23, 2013

creating word documents using open xml with asp.net

Now in this article i will explain how to use the Office Open XML C# (alternate solution to the Interop object. 

The Open XML provides you set of .NET API. It helps helps you manipulate and creating the documents in the Open XML Formats
in both the environments (i.e client and server both) and that is without help of MS office applications.

Before using Open XML Format, you have to add the below namespaces in your C# class. Add references to the Packaging and Spreadsheet API components with the following code.
 
 
using DocumentFormat.OpenXml;
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Wordprocessing;
 
Here is the CreateOpenXmlDocument function where you need to pass the filepath and it will created that doc file on specified positionl
 
public void CreateOpenXmlDocument(string filepath)
{
    
 using (WordprocessingDocument wordDocument = WordprocessingDocument.Create(filepath, WordprocessingDocumentType.Document))
  {
    // Add a main document part.
    MainDocumentPart mainPart = wordDocument.AddMainDocumentPart();

    mainPart.Document = new Document();
    Body body = mainPart.Document.AppendChild(new Body());
    Paragraph para = body.AppendChild(new Paragraph());
    Run run = para.AppendChild(new Run());
    run.AppendChild(new Text("Create text sample text, coding stuffs daily..."));
  }
}



Here now i am integrating that function into my page_load event.


protected void Page_Load(object sender, EventArgs e)
{

      string FilePath =  @"C:\\Temp";
      CreateWordprocessingDocument(FilePath);

      FileInfo myDoc = new FileInfo(FilePath);
      Response.Clear();
      Response.ContentType = "Application/msword";
      Response.AddHeader("content-disposition", "attachment;filename=" + myDoc.Name);
      Response.AddHeader("Content-Length", myDoc.Length.ToString());
      Response.ContentType = "application/octet-stream";
      Response.WriteFile(myDoc.FullName);
      Response.End();

}
 
 
This is just an sample doc creation , you may even format the document with adding images, graphs, style to para and may more. Just refer this Microsoft article on how to do this. 

feel free to raise your suggestion/comments on this. Thanks you and happy coding....


 
 
 

Wednesday, September 23, 2009

CSV to XML Conversion using LINQ

on C#, if we want to Convert CSV to XML then you can use Language Integrated Query (LINQ) can be used to convert a CSV file to XML. Here is the sample CSV file that needs to be converted

below example code reads the CSV file to an array. LINQ is used to loop through the array and the contents are written as XML using XElement (System.XML.Linq).


public void ConvCSVToXML()

{

String[] FileContent = File.ReadAllLines(@"D:\Proj\jquery.csv");

String XMLNS = "";

XElement Inv = new XElement("type", from

items in FileContent

let fields = items.Split(',')

select new XElement("fadein",

new XElement("Tab", fields[0]),

new XElement("ProgressBar", fields[1]),

new XElement("ToolTip", fields[2]),

new XElement("Menu", fields[3]),

)
);

File.WriteAllText(@"D:\Proj\jquery.xml", XMLNS + Inv.ToString() );
}


using this you can convert your CSV file xml using C# and C# Convert CSV To XML, .NET CSV To XML

Thursday, September 3, 2009

About XmlPreloadedResolver

when using Silverlight then XmlPreloadedResolver meaning is very useful, its a new type which can be useful when your working with XML . on XmlPreloadedResolver it has the Ability to load the DTD without call to network. This type manually maintain the DTD cache and all other with xml streams. XmlPreloadedResolver includes RSS1.0 and XHTML1.0 Defination of DTD.

sample code on how to work with XmlPreloadedResolver


String strDtd = "";
XmlPreloadedResolver resolver = new XmlPreloadedResolver();
resolver.Add(resolver.ResolveUri(null, "nameofDTD.dtd"), strDtd);
XmlReaderSettings rs = new XmlReaderSettings();
rs.XmlResolver = resolver;
rs.DtdProcessing = DtdProcessing.Parse;
XmlReader reader = XmlReader.Create("samplexml.xml", rs);



now you can also set the DTD sets Enable using XmlKnownDtds enumeration.
XmlKnownDtds is used with the XmlPreloadedResolver to identify the well-known DTD

the following example shos preloading Xhtml1.0 DTd into the XmlReaderSettings object
here there is no need of network call to parse the Xhtml file.it will done automatically.


XmlReaderSettings settings = new XmlReaderSettings();
//define the Setting object to parsing DTD
settings.DtdProcessing = DtdProcessing.Parse;
// Define preloading Xhtml10 DTD
settings.XmlResolver = new XmlPreloadedResolver(XmlKnownDtds.Xhtml10);
//suppose read the sample.html file using XmlReader
XmlReader reader = XmlReader.Create("sample.html", settings);
// and load using XDocument object
XDocument document = XDocument.Load(reader);


for more refer to : http://msdn.microsoft.com/en-us/library/cc189059(VS.95).aspx

Thursday, July 30, 2009

Export XML from SQL using a Stored Procedure.

1) Generate a file with the text-editor like:


<%begindetail%>
<%insert_data_here%>
<%enddetail%>


Save it as c:\temp\template.tpl

2) Open Query Analyzer and type:


sp_makewebtask @outputfile = 'c:\temp\myxmlfile.xml',
@query = 'select * from sysobjects for xml auto',
@templatefile = 'c:\temp\template.tpl'

The result is a XML-File!


More ^