Click here to Skip to main content
16,016,894 members

Comments by Sarath02 (Top 12 by date)

Sarath02 24-Apr-14 9:27am View    
This link is not help for me......can you explain with some example
Sarath02 24-Apr-14 9:25am View    
Here i am using xml document. i can't understand how to write the code. can you please help me....i will write my code here..just set the paths...please

Here is my c# code:

List<contact> Clist = new List<contact>();
string filename = Server.MapPath("index.xml");
XmlDocument doc = new XmlDocument();
doc.Load(filename);

XmlNode node = doc.SelectSingleNode("//test");
XmlNodeList nList = node.SelectNodes("tm/mc/cs");

foreach (XmlNode n in nList)
{
Contact con = new Contact();
con.sa1 = n.SelectSingleNode("t").InnerText;
con.sa2 = n.SelectSingleNode("mc").InnerText;
con.sa3 = n.SelectSingleNode("f").InnerText;

Clist.Add(con);
}
Sarath02 24-Apr-14 6:51am View    
These links are good related to Open XML SDK. But here my problem is create spreadsheet using xml file.

Ex: Here I have index.xml file, By using this xml file i want to create a spreadsheet
Sarath02 23-Apr-14 12:03pm View    
When i am creating a spreadsheet using following code. that will not created. even it is not showing any error also.

Along with that, i want to show some data when creating spreadsheet.
Ex: I want to show what is your name in spreadsheet.


Here is my code:

protected void Page_Load(object sender, EventArgs e)
{
string filename = @"c:/Users/Public/Documents/MySheet.xlsx";
CreateSpreadsheetWorkbook(filename);
}

public static void CreateSpreadsheetWorkbook(string filepath)
{
// Create a spreadsheet document by supplying the filepath.
// By default, AutoSave = true, Editable = true, and Type = xlsx.
SpreadsheetDocument spreadsheetDocument = SpreadsheetDocument.
Create(filepath, SpreadsheetDocumentType.Workbook);

// Add a WorkbookPart to the document.
WorkbookPart workbookpart = spreadsheetDocument.AddWorkbookPart();
workbookpart.Workbook = new Workbook();

// Add a WorksheetPart to the WorkbookPart.
WorksheetPart worksheetPart = workbookpart.AddNewPart<worksheetpart>();
worksheetPart.Worksheet = new Worksheet(new SheetData());

// Add Sheets to the Workbook.
Sheets sheets = spreadsheetDocument.WorkbookPart.Workbook.
AppendChild<sheets>(new Sheets());

// Append a new worksheet and associate it with the workbook.
Sheet sheet = new Sheet()
{
Id = spreadsheetDocument.WorkbookPart.
GetIdOfPart(worksheetPart),
SheetId = 1,
Name = "mySheet"
};
sheets.Append(sheet);

workbookpart.Workbook.Save();

// Close the document.
spreadsheetDocument.Close();
}
Sarath02 23-Apr-14 10:42am View    
ya ok sorry for that...Here i will explain clearly now....

I want to show what is your name in spreadsheet. than how can i show that can you explain