Я хочу иметь возможность добавлять простые формулы в libxl, такие как сложение и вычитание, просто не знаю, как это сделать. Просто интересно, как добавить простые формулы сложения и вычитания.Как встраивать формулы в libxl для ios
Вот мой код:.
- (IBAction)createExcel:(id)sender
{
NSLog(@"createExcel");
BookHandle book = xlCreateBook(); // use xlCreateXMLBook() for working with xlsx files
SheetHandle sheet = xlBookAddSheet(book, "Sheet1", NULL);
Эти цифры, которые я хочу формулы изменить (100 & 150)
xlSheetWriteStr(sheet, 1, 0, 100, 0);
xlSheetWriteStr(sheet, 1, 0, 150, 0);
NSString *documentPath =
[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES) objectAtIndex:0];
NSString *filename = [documentPath stringByAppendingPathComponent:@"insuranceclaim.xls"];
xlBookSave(book, [filename UTF8String]);
xlBookRelease(book);
if (![MFMailComposeViewController canSendMail]) {
//Show alert that device cannot send email, this is because an email account hasn't been setup.
}
else {
//**EDIT HERE**
//Use this to retrieve your recently saved file
NSString *documentPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES) objectAtIndex:0];
NSString *filename = [documentPath stringByAppendingPathComponent:@"insuranceclaim.xls"];
//**END OF EDIT**
NSString *mimeType = @"application/vnd.ms-excel"; //This should be the MIME type for els files. May want to double check.
NSData *fileData = [NSData dataWithContentsOfFile:filename];
NSString *fileNameWithExtension = self.personFirstnameTextField.text; //This is what you want the file to be called on the email along with it's extension:
//If you want to then delete the file:
NSError *error;
if (![[NSFileManager defaultManager] removeItemAtPath:filename error:&error])
NSLog(@"ERROR REMOVING FILE: %@", [error localizedDescription]);
}
}
Спасибо, чувак! Ценить это! –
Я продолжаю использовать необъявленный идентификатор для жирного формата, вы знаете, почему? Как я могу это объявить? –
Проверьте документацию, к которой я привязан. Вы можете всегда передавать 0 для формата. –