objective c - How to create multiple sheets using RSSheet in iOS? -


i trying create xls sheet programmatically. able create single sheet in xls file, when try create 2 sheets, error. file created unable open file. can open file when created single sheet.

here tried:

rsworkbook * folder = [ [rsworkbook alloc] init]; folder.author = @"andrea cappellotto"; folder.version = 1.2;  rsworksheet * sheet = [[rsworksheet alloc] initwithname:@"prova"]; rsworksheet * sheet2 = [[rsworksheet alloc] initwithname:@"222"];  rsworksheetrow * row = [[rsworksheetrow alloc] initwithheight:20]; [row addcellstring:@"prova"]; [row addcellstring:@"prova2"]; [sheet addworksheetrow:row]; [sheet2 addworksheetrow:row];  rsworksheetrow * row2 = [[rsworksheetrow alloc] initwithheight:25]; [row2 addcellnumber:100]; [row2 addcelldata:[nsdate date] ]; [sheet addworksheetrow:row2]; [sheet2 addworksheetrow:row];  [folder addworksheet:sheet]; [folder addworksheet:sheet2];  nsarray *documentpaths = nssearchpathfordirectoriesindomains(nsdocumentdirectory, nsuserdomainmask, yes); nsstring *documentsdir = [documentpaths objectatindex:0]; [folder writewithname:@"prova" topath:documentsdir]; 

here xml code generated:

<?xml version="1.0" encoding="utf-8"?> <?mso-application progid="excel.sheet"?> <workbook xmlns:c="urn:schemas-microsoft-com:office:component:spreadsheet"  xmlns:html="http://www.w3.org/tr/rec-html40"  xmlns:o="urn:schemas-microsoft-com:office:office"  xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"  xmlns="urn:schemas-microsoft-com:office:spreadsheet"  xmlns:x2="http://schemas.microsoft.com/office/excel/2003/xml"  xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"  xmlns:x="urn:schemas-microsoft-com:office:excel"> <documentproperties xmlns="urn:schemas-microsoft-com:office:office"><author>andrea cappellotto</author> <lastauthor>andrea cappellotto</lastauthor> <created>2015-07-09</created> <version>1.20</version> </documentproperties> <officedocumentsettings xmlns="urn:schemas-microsoft-com:office:office"> </officedocumentsettings> <excelworkbook xmlns="urn:schemas-microsoft-com:office:excel"> <windowheight>20000</windowheight> <windowwidth>20000</windowwidth> <windowtopx>0</windowtopx> <windowtopy>0</windowtopy> <protectstructure>false</protectstructure> <protectwindows>false</protectwindows> </excelworkbook><styles><style ss:id="default" ss:name="normal"> <alignment ss:vertical="center" ss:horizontal="center"/> <borders/> <font ss:fontname=".helveticaneueinterface-regular" ss:size="14.00" ss:color="#000000"/> <interior/> <numberformat/> <protection/> </style> <style ss:id="s60"> <numberformat ss:format="short date"/> </style> </styles> <worksheet ss:name="prova"> <table ss:expandedcolumncount="2" ss:expandedrowcount="2" x:fullcolumns="1" x:fullrows="1" ss:defaultcolumnwidth="0.00" ss:defaultrowheight="20.00"> <column ss:width="80"/> <row ss:autofitheight="0" ss:height="20.00" > <cell> <data ss:type="string">prova</data> </cell> <cell> <data ss:type="string">prova2</data> </cell> </row> <row ss:autofitheight="0" ss:height="25.00" > <cell> <data ss:type="number">100.00</data> </cell> <cell ss:styleid="s60"> <data ss:type="datetime">2015-07-09</data> </cell> </row> </table> <worksheetoptions/> </worksheet> <worksheet ss:name="222"> <table ss:expandedcolumncount="2" ss:expandedrowcount="2" x:fullcolumns="1" x:fullrows="1" ss:defaultcolumnwidth="0.00" ss:defaultrowheight="20.00"> <column ss:width="80"/> <row ss:autofitheight="0" ss:height="20.00" > <cell> <data ss:type="string">prova</data> </cell> <cell> <data ss:type="string">prova2</data> </cell> </row> <row ss:autofitheight="0" ss:height="20.00" > <cell> <data ss:type="string">prova</data> </cell> <cell> <data ss:type="string">prova2</data> </cell> </row> </table> <worksheetoptions/> </worksheet> </workbook> 

i found library create multiple sheets in xls file. libxl.i can add many sheets can using following line:

 sheethandle sheet = xlbookaddsheet(book, [sheetname utf8string], null); 

Comments