First create a NSMutableString variable
NSMutableString *excel = [[NSMutableString alloc] init];
and then build up your string with a header, then the spreadsheet header, then data and finally a closing section.
1. Header - Below lines should be added to the start of XML string -
[excel appendString:@"<?xml version=\"1.0\"?>\n<?mso-a
[excel appendString:@"xmlns:x=\"u
[excel appendString:@"<LastAuthor
[excel appendString:[NSString stringWithFormat:@"<Create
[excel appendString:@"<Version>11
[excel appendString:@"<WindowTopX
[excel appendString:@"<Style ss:ID=\"Default\" ss:Name=\"Normal\">\n<Alig
[excel appendString:@"<Style ss:ID=\"s21\">\n<NumberFor
2. Add the following code to create Worksheets and Table headings -
[excel appendString:@"<Worksheet ss:Name=\"User\">"];
[excel appendString:@"<Table ss:ExpandedColumnCount=\"8
[excel appendString:@"<Row>"];
[excel appendString:@"<Cell><Data
[excel appendString:@"<Cell><Data
[excel appendString:@"<Cell><Data
[excel appendString:@"<Cell><Data
[excel appendString:@"<Cell><Data
[excel appendString:@"<Cell><Data
[excel appendString:@"<Cell><Data
[excel appendString:@"<Cell><Data
"ss:Name" will be the name of your worksheet
"ss:ExpandedColumnCount=\
"ss:ExpandedRowCount=\"2\
Above, I have then defined the column headers (just for an example). They are the ones beginning with <Cell>
After this add your dynamic data for each column using loop or whatever way you prefer. Like
[excel appendString:@"<Row>"];
[excel appendString:[NSString stringWithFormat:@"<Cell><
[excel appendString:[NSString stringWithFormat:@"<Cell><
[excel appendString:[NSString stringWithFormat:@"<Cell><
[excel appendString:[NSString stringWithFormat:@"<Cell><
[excel appendString:[NSString stringWithFormat:@"<Cell><
[excel appendString:[NSString stringWithFormat:@"<Cell><
[excel appendString:[NSString stringWithFormat:@"<Cell><
[excel appendString:[NSString stringWithFormat:@"<Cell><
Then add the following code to close your worksheet.
[excel appendString:@"</Table><Wo
[excel appendString:@"<Selected/>
[excel appendString:@"<Number>3</
[excel appendString:@"</Pane></Pa
[excel appendString:@"<ProtectSce
you can follow the above step for each spreadsheet (if you want to create more than one)
And in the end add the closing tag to close your workbook.
[excel appendString:@"</Workbook>
Save this "as file" and you can mail to any mail address. Sample "XML" File attached.
Enjoy coding.
Thanks
Nishant Trivedi