Tworzenie plików Excel XLS na iOS
Próbuję utworzyć raport w formacie Excel, gotowy do wysłania pocztą elektroniczną. Jak dotąd odkryłem, że najlepszym i najprostszym sposobem jest utworzenie dokumentu xml w następujący sposób i zapisanie go jako xls.
<?xml version="1.0"?>
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:html="http://www.w3.org/TR/REC-html40">
<Worksheet ss:Name="Sheet1">
<Table ss:ExpandedColumnCount="2" ss:ExpandedRowCount="2" x:FullColumns="1" x:FullRows="1">
<Row>
<Cell><Data ss:Type="String">Name</Data></Cell>
<Cell><Data ss:Type="String">Example</Data></Cell>
</Row>
<Row>
<Cell><Data ss:Type="String">Value</Data></Cell>
<Cell><Data ss:Type="Number">123</Data></Cell>
</Row>
</Table>
</Worksheet>
</Workbook>
Wtedy mógłbym zapisać ten dokument za pomocą
NSArray *documentDirectoryPath = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *docDir = [NSString stringWithFormat:@"%@/Report.xls", [documentDirectoryPath objectAtIndex:0]];
[xmlString writeToFile:docDir atomically:YES encoding:NSUTF8StringEncoding error:NULL];
[serializedData writeToFile:docDir atomically:YES];
Jednak po wysłaniu wiadomości e-mail i próbie otwarcia pliku xls plik xml jest wyświetlany w arkuszu kalkulacyjnym. Czy ktoś mógłby mnie poprowadzić w dobrym kierunku, aby utworzyć ten plik xls?