Guest User

Untitled

a guest
Jul 21st, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. // Path of output Excel file
  2. intrusive_ptr<Aspose::Cells::System::String> outputCenterAlignExcelCell = new Aspose::Cells::System::String("D:\\Download\\outputCenterAlignExcelCell.xlsx");
  3.  
  4. // Create empty Workbook object.
  5. intrusive_ptr<IWorkbook> wb = Factory::CreateIWorkbook();
  6.  
  7. // Access first worksheet.
  8. intrusive_ptr<Aspose::Cells::IWorksheet> ws = wb->GetIWorksheets()->GetObjectByIndex(0);
  9.  
  10. // Access cell C4.
  11. intrusive_ptr<Aspose::Cells::System::String> cellName = new Aspose::Cells::System::String("C4");
  12. intrusive_ptr<Aspose::Cells::ICell> c4 = ws->GetICells()->GetObjectByIndex(cellName);
  13.  
  14. // Add some text inside it.
  15. intrusive_ptr<Aspose::Cells::System::String> cellText = new Aspose::Cells::System::String("Aspose File Format APIs");
  16. c4->PutValue(cellText);
  17.  
  18. // Access cell style.
  19. intrusive_ptr<Aspose::Cells::IStyle> st = c4->GetIStyle();
  20.  
  21. // Set the horizontal and vertical alignment of the cell style.
  22. st->SetHorizontalAlignment(Aspose::Cells::TextAlignmentType::TextAlignmentType_Center);
  23. st->SetVerticalAlignment(Aspose::Cells::TextAlignmentType::TextAlignmentType_Center);
  24.  
  25. // Set the font color to red.
  26. st->GetIFont()->SetColor(Aspose::Cells::System::Drawing::Color::GetRed());
  27.  
  28. // Set the cell style.
  29. c4->SetIStyle(st);
  30.  
  31. // Set the cell's column width and row height.
  32. ws->GetICells()->SetColumnWidth(c4->GetColumn(), 30);
  33. ws->GetICells()->SetRowHeight(c4->GetRow(), 40);
  34.  
  35. // Save the workbook in output Excel format.
  36. wb->Save(outputCenterAlignExcelCell, SaveFormat_Xlsx);
Add Comment
Please, Sign In to add comment