在iphone程序中打开word、execl、pdf等文档

用UIWebView就可以了
-(void)loadDocument:(NSString*)documentName inView:(UIWebView*)webView
{
    NSString *path = [[NSBundle mainBundle] pathForResource:documentName ofType:nil];
    NSURL *url = [NSURL fileURLWithPath:path];
    NSURLRequest *request = [NSURLRequest requestWithURL:url];
    [webView loadRequest:request];
}

// Calling -loadDocument:inView:
[self loadDocument:@"test.doc" inView:self.myWebview];
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要将 Excel 文件转换为 PDF 文件,可以使用 Apache POI 和 iText 库。以下是使用这两个库将 Excel 文件转换为 PDF 文件的基本步骤: 1. 使用 Apache POI 库加载 Excel 文件并将其读入 HSSFWorkbook 对象中。 2. 遍历 Excel 文件中的所有工作表,并将它们转换为 PDF。 3. 对于每个工作表,创建一个 PDF 文档,并将其写入 iText 的 Document 对象中。 4. 遍历 Excel 工作表中的所有行和列,将单元格中的数据写入 PDF 文件中。 5. 最后,保存 PDF 文件。 以下是示例代码: ```java import java.io.FileOutputStream; import java.io.IOException; import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.ss.usermodel.*; import com.itextpdf.text.Document; import com.itextpdf.text.PageSize; import com.itextpdf.text.pdf.PdfWriter; public class ExcelToPDFConverter { public static void main(String[] args) throws IOException { // Load Excel file into HSSFWorkbook object Workbook workbook = new HSSFWorkbook(new FileInputStream("input.xls")); // Create new PDF document Document document = new Document(PageSize.A4, 50, 50, 50, 50); PdfWriter.getInstance(document, new FileOutputStream("output.pdf")); document.open(); // Loop through each sheet in Excel file for (int i = 0; i < workbook.getNumberOfSheets(); i++) { Sheet sheet = workbook.getSheetAt(i); // Create new page in PDF document document.newPage(); // Loop through each row and column in sheet for (int row = 0; row < sheet.getPhysicalNumberOfRows(); row++) { for (int col = 0; col < sheet.getRow(row).getPhysicalNumberOfCells(); col++) { // Get cell value and write to PDF document Cell cell = sheet.getRow(row).getCell(col); if (cell != null) { document.add(new com.itextpdf.text.Paragraph(cell.toString())); } } } } // Close PDF document and save document.close(); } } ``` 请注意,这只是一个简单的示例代码。在实际应用中,您可能需要添加更多的错误处理和格式设置代码。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值