Last active
March 7, 2017 11:16
-
-
Save aspose-cells/e5c37fcb9f5ce13b9fcf960e73de0de9 to your computer and use it in GitHub Desktop.
This Gist contains Android code snippets for examples of Aspose.Cells for Android.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Examples-Android |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
//Get the path of Aspose directory inside the SD Card | |
String SD_PATH = Environment.getExternalStorageDirectory().toString() + "/Aspose/"; | |
//Create an instance of Workbook | |
Workbook book = new Workbook(); | |
//Access first worksheet from the collection | |
Worksheet sheet = book.getWorksheets().get(0); | |
//Access ShapeCollection of first worksheet | |
ShapeCollection shapes = sheet.getShapes(); | |
//Add WordArt with built-in styles | |
shapes.addWordArt(PresetWordArtStyle.WORD_ART_STYLE_1, "Aspose File Format APIs", 00, 0, 0, 0, 100, 800); | |
shapes.addWordArt(PresetWordArtStyle.WORD_ART_STYLE_2, "Aspose File Format APIs", 10, 0, 0, 0, 100, 800); | |
shapes.addWordArt(PresetWordArtStyle.WORD_ART_STYLE_3, "Aspose File Format APIs", 20, 0, 0, 0, 100, 800); | |
shapes.addWordArt(PresetWordArtStyle.WORD_ART_STYLE_4, "Aspose File Format APIs", 30, 0, 0, 0, 100, 800); | |
shapes.addWordArt(PresetWordArtStyle.WORD_ART_STYLE_5, "Aspose File Format APIs", 40, 0, 0, 0, 100, 800); | |
//Save the result in XLSX format | |
book.save(SD_PATH + "outputAddingWordArtwithBuiltinStyles.xlsx"); | |
Log.w(TAG, "outputAddingWordArtwithBuiltinStyles.xlsx created successfully"); | |
} catch (Exception ex) { | |
Log.e(TAG, "Some exception occurred in AddingWordArtwithBuiltinStyles"); | |
Log.e(TAG, "Exception: " + ex.getMessage()); | |
Log.e(TAG, "StackTrace: " + Log.getStackTraceString(ex)); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
//Get the path of Aspose directory inside the SD Card | |
String SD_PATH = Environment.getExternalStorageDirectory().toString() + "/Aspose/"; | |
// Create a workbook | |
Workbook book = new Workbook(); | |
// URL that contains your XML data for mapping | |
String XML = "https://docs.aspose.com/download/attachments/5018589/sampleXML.txt"; | |
// Import your XML Map data starting from cell A1 | |
book.importXml(XML, "Sheet1", 0, 0); | |
//Save the result in XLSX format | |
book.save(SD_PATH + "outputAddingXMLMaptoWorkbook.xlsx"); | |
Log.w(TAG, "outputAddingWordArtwithBuiltinStyles.xlsx created successfully"); | |
} catch (Exception ex) { | |
Log.e(TAG, "Some exception occurred in AddingXMLMaptoWorkbook"); | |
Log.e(TAG, "Exception: " + ex.getMessage()); | |
Log.e(TAG, "StackTrace: " + Log.getStackTraceString(ex)); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try | |
{ | |
//Get the path of Aspose directory inside the SD Card | |
String SD_PATH = Environment.getExternalStorageDirectory().toString() + "/Aspose/"; | |
//Create an instance of Workbook | |
Workbook book = new Workbook(); | |
//Access first worksheet from the collection | |
Worksheet sheet = book.getWorksheets().get(0); | |
//Add column headings in cell A1 and B1 | |
sheet.getCells().get(0, 0).putValue("Column A"); | |
sheet.getCells().get(0, 1).putValue("Column B"); | |
//Add list object, set its name and style | |
ListObject listObject = sheet.getListObjects().get(sheet.getListObjects().add(0, 0, 1, sheet.getCells().getMaxColumn(), true)); | |
listObject.setTableStyleType(TableStyleType.TABLE_STYLE_MEDIUM_14); | |
listObject.setDisplayName("Table"); | |
//Set the formula of second column so that it could automatically propagate to new rows while entering data | |
listObject.getListColumns().get(1).setFormula("=[Column A] + 1"); | |
//Save the result in XLSX format | |
book.save(SD_PATH + "outputAutomaticallyPropagateFormulainExcelTable.xlsx"); | |
Log.w(TAG, "outputAutomaticallyPropagateFormulainExcelTable.xlsx created successfully"); | |
} | |
catch (Exception ex) | |
{ | |
Log.e(TAG, "Some exception occurred in AutomaticallyPropagateFormulainExcelTable"); | |
Log.e(TAG, "Exception: " + ex.getMessage()); | |
Log.e(TAG, "StackTrace: " + Log.getStackTraceString(ex)); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
//Read the sample workbook from assest | |
AssetManager assetManager = context.getAssets(); | |
InputStream in = assetManager.open("sampleChangingtheAbsolutePathofExternalDataSource.xlsx"); | |
//Load your source excel file containing the external link | |
Workbook wb = new Workbook(in); | |
//Access the first external link | |
ExternalLink externalLink = wb.getWorksheets().getExternalLinks().get(0); | |
//Print the data source of external link, it will print existing remote path | |
System.out.println("External Link Data Source: " + externalLink.getDataSource()); | |
// Remove the remote path and print the new data source | |
// Assign the new data source to external link and print again, it will now print data source with local path | |
externalLink.setDataSource("ExternalAccounts.xlsx"); | |
Log.w(TAG, "External Link Data Source After Removing Remote Path: " + externalLink.getDataSource()); | |
// Change the absolute path of the workbook, it will also change the external link path | |
wb.setAbsolutePath("C:\\Files\\Extra\\"); | |
// Now print the data source again | |
Log.w(TAG, "External Link Data Source After Changing Workbook.AbsolutePath to Local Path: " + externalLink.getDataSource()); | |
// Change the absolute path of the workbook to some remote path, it will again affect the external link path | |
wb.setAbsolutePath("http://www.aspose.com/WebFiles/ExcelFiles/"); | |
// Now print the data source again | |
Log.w(TAG, "External Link Data Source After Changing Workbook.AbsolutePath to Remote Path: " + externalLink.getDataSource()); | |
Log.w(TAG, "------------------------------------------"); | |
Log.w(TAG, "ChangingtheAbsolutePathofExternalDataSource executed successfully"); | |
} catch (Exception ex) { | |
Log.e(TAG, "Some exception occurred in ChangingtheAbsolutePathofExternalDataSource"); | |
Log.e(TAG, "Exception: " + ex.getMessage()); | |
Log.e(TAG, "StackTrace: " + Log.getStackTraceString(ex)); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
//Get the path of Aspose directory inside the SD Card | |
String SD_PATH = Environment.getExternalStorageDirectory().toString() + "/Aspose/"; | |
// Create a Style object using CellsFactory class | |
CellsFactory cf = new CellsFactory(); | |
Style st = cf.createStyle(); | |
// Set the Style fill color to Yellow | |
st.setPattern(BackgroundType.SOLID); | |
st.setForegroundColor(Color.getYellow()); | |
// Create a workbook and set its default style using the created Style object | |
Workbook wb = new Workbook(); | |
wb.setDefaultStyle(st); | |
//Save the result in XLSX format | |
wb.save(SD_PATH + "outputCreatingStyleObjectWithoutAddingittoStyleCollection.xlsx"); | |
Log.w(TAG, "outputCreatingStyleObjectWithoutAddingittoStyleCollection.xlsx created successfully"); | |
} catch (Exception ex) { | |
Log.e(TAG, "Some exception occurred in CreatingStyleObjectWithoutAddingittoStyleCollection"); | |
Log.e(TAG, "Exception: " + ex.getMessage()); | |
Log.e(TAG, "StackTrace: " + Log.getStackTraceString(ex)); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
//Get the path of Aspose directory inside the SD Card | |
String SD_PATH = Environment.getExternalStorageDirectory().toString() + "/Aspose/"; | |
//Read the sample workbook from assest | |
AssetManager assetManager = context.getAssets(); | |
InputStream in = assetManager.open("sampleExportingXMLMapData.xlsx"); | |
//Load source workbook | |
Workbook wb = new Workbook(in); | |
//Export all XML data from all XML Maps inside the Workbook | |
for (int i = 0; i < wb.getWorksheets().getXmlMaps().getCount(); i++) | |
{ | |
//Access the XML Map | |
XmlMap map = wb.getWorksheets().getXmlMaps().get(i); | |
//Exports its XML Data | |
wb.exportXml(map.getName(), SD_PATH + map.getName() + ".xml"); | |
} | |
Log.w(TAG, "ExportingXMLMapData executed successfully"); | |
} catch (Exception ex) { | |
Log.e(TAG, "Some exception occurred in ExportingXMLMapData"); | |
Log.e(TAG, "Exception: " + ex.getMessage()); | |
Log.e(TAG, "StackTrace: " + Log.getStackTraceString(ex)); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
//Create an instance of LoadOptions class | |
LoadOptions options = new LoadOptions(); | |
//Create an instance of LoadFilter class | |
//Select to load document properties by passing LoadDataFilterOptions.DocumentProperties to constructor | |
LoadFilter filter = new LoadFilter(LoadDataFilterOptions.DOCUMENT_PROPERTIES); | |
//Set the LoadFilter property of LoadOptions object to the instance of LoadFilter class created above | |
options.setLoadFilter(filter); | |
//Load a template file by passing file path as well as instance of LoadOptions class | |
Workbook book = new Workbook(SD_PATH + "sample.xlsx", options); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
//Create an instance of LoadOptions class | |
LoadOptions options = new LoadOptions(); | |
//Create an instance of LoadFilter class | |
//Select to load document properties by passing parameter to the constructor | |
LoadFilter filter = new LoadFilter(LoadDataFilterOptions.ALL & ~LoadDataFilterOptions.CHART); | |
//Set the LoadFilter property of LoadOptions object to the instance of LoadFilter class created above | |
options.setLoadFilter(filter); | |
//Load a template file by passing file path as well as instance of LoadOptions class | |
Workbook book = new Workbook(SD_PATH + "sample.xlsx", options); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try | |
{ | |
String SD_PATH = Environment.getExternalStorageDirectory().toString() + "/Aspose/"; | |
//Read the sample workbook from assest | |
AssetManager assetManager = context.getAssets(); | |
InputStream in = assetManager.open("sampleLinkingCellstoXMLMapElements.xlsx"); | |
//Load a sample spreadsheet | |
Workbook book = new Workbook(in); | |
//Access the XML Map from the spreadsheet | |
XmlMap map = book.getWorksheets().getXmlMaps().get(0); | |
//Access first worksheet from the collection | |
Worksheet sheet = book.getWorksheets().get(0); | |
//Map FIELD1 and FIELD2 to cell A1 and B2 | |
sheet.getCells().linkToXmlMap(map.getName(), 0, 0, "/root/row/FIELD1"); | |
sheet.getCells().linkToXmlMap(map.getName(), 1, 1, "/root/row/FIELD2"); | |
//Map FIELD4 and FIELD5 to cell C3 and D4 | |
sheet.getCells().linkToXmlMap(map.getName(), 2, 2, "/root/row/FIELD4"); | |
sheet.getCells().linkToXmlMap(map.getName(), 3, 3, "/root/row/FIELD5"); | |
//Map FIELD7 and FIELD8 to cell E5 and F6 | |
sheet.getCells().linkToXmlMap(map.getName(), 4, 4, "/root/row/FIELD7"); | |
sheet.getCells().linkToXmlMap(map.getName(), 5, 5, "/root/row/FIELD8"); | |
//Save the result in XLSX format | |
book.save(SD_PATH + "outputLinkingCellstoXMLMapElements.xlsx"); | |
Log.w(TAG, "outputLinkingCellstoXMLMapElements.xlsx created successfully"); | |
} | |
catch (Exception ex) | |
{ | |
Log.e(TAG, "Some exception occurred in LinkingCellstoXMLMapElements"); | |
Log.e(TAG, "Exception: " + ex.getMessage()); | |
Log.e(TAG, "StackTrace: " + Log.getStackTraceString(ex)); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
//Get the path of Aspose directory inside the SD Card | |
String SD_PATH = Environment.getExternalStorageDirectory().toString() + "/Aspose/"; | |
//Read the sample workbook from assest | |
AssetManager assetManager = context.getAssets(); | |
InputStream in = assetManager.open("sampleManaging3DEffectsforShapes.xlsx"); | |
//Load a sample spreadsheet containing a shape | |
Workbook book = new Workbook(in); | |
//Access first worksheet from the collection | |
Worksheet sheet = book.getWorksheets().get(0); | |
//Access first shape from the collection | |
Shape shape = sheet.getShapes().get(0); | |
//Get the instance of ThreeDFormat from the Shape object | |
ThreeDFormat threeD = shape.getThreeDFormat(); | |
//Set its ContourWidth & ExtrusionHeight properties | |
threeD.setContourWidth(15); | |
threeD.setExtrusionHeight(30); | |
//Save the result in XLSX format | |
book.save(SD_PATH + "outputManaging3DEffectsforShapes.xlsx"); | |
Log.w(TAG, "outputManaging3DEffectsforShapes.xlsx created successfully"); | |
} | |
catch (Exception ex) { | |
Log.e(TAG, "Some exception occurred in Managing3DEffectsforShapes"); | |
Log.e(TAG, "Exception: " + ex.getMessage()); | |
Log.e(TAG, "StackTrace: " + Log.getStackTraceString(ex)); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
//Get the path of Aspose directory inside the SD Card | |
String SD_PATH = Environment.getExternalStorageDirectory().toString() + "/Aspose/"; | |
//Read the sample workbook from assest | |
AssetManager assetManager = context.getAssets(); | |
InputStream in = assetManager.open("sampleManagingGlowEffectsforShape.xlsx"); | |
//Load a sample spreadsheet containing a shape | |
Workbook book = new Workbook(in); | |
//Access first worksheet from the collection | |
Worksheet sheet = book.getWorksheets().get(0); | |
//Access first shape from the collection | |
Shape shape = sheet.getShapes().get(0); | |
//Get the instance of GlowEffect from the Shape object | |
GlowEffect glow = shape.getGlow(); | |
//Set its Size & Transparency properties | |
glow.setSize(90); | |
glow.setTransparency(0.5); | |
//Save the result in XLSX format | |
book.save(SD_PATH + "outputManagingGlowEffectsforShape.xlsx"); | |
Log.w(TAG, "outputManagingGlowEffectsforShape.xlsx created successfully"); | |
} catch (Exception ex) { | |
Log.e(TAG, "Some exception occurred in ManagingGlowEffectsforShape"); | |
Log.e(TAG, "Exception: " + ex.getMessage()); | |
Log.e(TAG, "StackTrace: " + Log.getStackTraceString(ex)); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
//Get the path of Aspose directory inside the SD Card | |
String SD_PATH = Environment.getExternalStorageDirectory().toString() + "/Aspose/"; | |
//Read the sample workbook from assest | |
AssetManager assetManager = context.getAssets(); | |
InputStream in = assetManager.open("sampleManagingReflectionEffectsforShapes.xlsx"); | |
//Load a sample spreadsheet containing a shape | |
Workbook book = new Workbook(in); | |
// Access first worksheet | |
Worksheet ws = book.getWorksheets().get(0); | |
// Access first shape | |
Shape sh = ws.getShapes().get(0); | |
// Set the reflection effect of the shape | |
// Set its Blur, Size, Transparency and Distance properties | |
ReflectionEffect re = sh.getReflection(); | |
re.setBlur(30); | |
re.setSize(90); | |
re.setTransparency(0); | |
re.setDistance(80); | |
//Save the result in XLSX format | |
book.save(SD_PATH + "outputManagingReflectionEffectsforShapes.xlsx"); | |
Log.w(TAG, "outputManagingReflectionEffectsforShapes.xlsx created successfully"); | |
} catch (Exception ex) { | |
Log.e(TAG, "Some exception occurred in AddingWordArtwithBuiltinStyles"); | |
Log.e(TAG, "Exception: " + ex.getMessage()); | |
Log.e(TAG, "StackTrace: " + Log.getStackTraceString(ex)); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
//Get the path of Aspose directory inside the SD Card | |
String SD_PATH = Environment.getExternalStorageDirectory().toString() + "/Aspose/"; | |
//Create workbook | |
Workbook wb = new Workbook(); | |
//Setting ScaleCrop and LinksUpToDate BuiltInDocumentProperties | |
wb.getBuiltInDocumentProperties().setScaleCrop(true); | |
wb.getBuiltInDocumentProperties().setLinksUpToDate(true); | |
//Save the result in XLSX format | |
wb.save(SD_PATH + "outputManagingScaleCropandLinksUpToDateBuiltInDocumentProperties.xlsx"); | |
Log.w(TAG, "outputManagingScaleCropandLinksUpToDateBuiltInDocumentProperties.xlsx created successfully"); | |
} catch (Exception ex) { | |
Log.e(TAG, "Some exception occurred in ChangingtheAbsolutePathofExternalDataSource"); | |
Log.e(TAG, "Exception: " + ex.getMessage()); | |
Log.e(TAG, "StackTrace: " + Log.getStackTraceString(ex)); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try | |
{ | |
//Get the path of Aspose directory inside the SD Card | |
String SD_PATH = Environment.getExternalStorageDirectory().toString() + "/Aspose/"; | |
//Read the sample workbook from assest | |
AssetManager assetManager = context.getAssets(); | |
InputStream in = assetManager.open("sampleManagingShadowEffectsforShape.xlsx"); | |
//Load a sample spreadsheet containing a shape | |
Workbook book = new Workbook(in); | |
//Access first worksheet from the collection | |
Worksheet sheet = book.getWorksheets().get(0); | |
//Access first shape from the collection | |
Shape shape = sheet.getShapes().get(0); | |
//Get the instance of ShadowEffect from the Shape object | |
ShadowEffect shadow = shape.getShadowEffect(); | |
//Set its Angle, Blur, Size, Transparency and Distance properties | |
shadow.setAngle(150); | |
shadow.setBlur(30); | |
shadow.setSize(0.9); | |
shadow.setTransparency(0.5); | |
shadow.setDistance(80); | |
//Save the result in XLSX format | |
book.save(SD_PATH + "outputManagingShadowEffectsforShape.xlsx"); | |
Log.w(TAG, "outputManagingShadowEffectsforShape.xlsx created successfully"); | |
} | |
catch (Exception ex) | |
{ | |
Log.e(TAG, "Some exception occurred in ManagingShadowEffectsforShape"); | |
Log.e(TAG, "Exception: " + ex.getMessage()); | |
Log.e(TAG, "StackTrace: " + Log.getStackTraceString(ex)); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try | |
{ | |
//Get the path of Aspose directory inside the SD Card | |
String SD_PATH = Environment.getExternalStorageDirectory().toString() + "/Aspose/"; | |
//Create workbook object | |
Workbook book = new Workbook(); | |
//Access first worksheet from the collection | |
Worksheet sheet = book.getWorksheets().get(0); | |
//Create a TextBox with some text | |
int index = sheet.getTextBoxes().add(0, 0, 100, 700); | |
TextBox textBox = (TextBox)sheet.getShapes().get(index); | |
textBox.setText("Aspose File Format APIs"); | |
textBox.getFont().setSize(44); | |
//Set preset WordArt style to the text of the shape | |
FontSetting fntSetting = (FontSetting)textBox.getCharacters().get(0); | |
fntSetting.setWordArtStyle(PresetWordArtStyle.WORD_ART_STYLE_15); | |
//Save the result in XLSX format | |
book.save(SD_PATH + "outputSettingPresetWordArtStylestoShapeText.xlsx"); | |
Log.w(TAG, "outputSettingPresetWordArtStylestoShapeText.xlsx created successfully"); | |
} | |
catch (Exception ex) | |
{ | |
Log.e(TAG, "Some exception occurred in SettingPresetWordArtStylestoShapeText"); | |
Log.e(TAG, "Exception: " + ex.getMessage()); | |
Log.e(TAG, "StackTrace: " + Log.getStackTraceString(ex)); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
public class CustomSettings extends GlobalizationSettings | |
{ | |
public String getTotalName(int functionType) | |
{ | |
switch (functionType) | |
{ | |
case ConsolidationFunction.AVERAGE: | |
return "AVG"; | |
default: | |
return super.getTotalName(functionType); | |
} | |
} | |
public String getGrandTotalName(int functionType) | |
{ | |
switch (functionType) | |
{ | |
case ConsolidationFunction.AVERAGE: | |
return "GRAND AVG"; | |
default: | |
return super.getGrandTotalName(functionType); | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
//Get the path of Aspose directory inside the SD Card | |
String SD_PATH = Environment.getExternalStorageDirectory().toString() + "/Aspose/"; | |
//Read the sample workbook from assest | |
AssetManager assetManager = context.getAssets(); | |
InputStream in = assetManager.open("sampleCustomLabelsForSubtotals.xlsx"); | |
//Load a sample spreadsheet containing a shape | |
Workbook book = new Workbook(in); | |
//Assigns the GlobalizationSettings property of the WorkbookSettings class | |
//to the class created in first step | |
book.getSettings().setGlobalizationSettings(new CustomSettings()); | |
//Accesses the 1st worksheet from the collection which contains data | |
//Data resides in the cell range A2:B9 | |
Worksheet sheet = book.getWorksheets().get(0); | |
//Adds SubTotal of type Average to the worksheet | |
sheet.getCells().subtotal(CellArea.createCellArea("A2", "B9"), 0, ConsolidationFunction.AVERAGE, new int[] { 0,1 }); | |
//Calculates Formulas | |
book.calculateFormula(); | |
//Auto fits all columns | |
sheet.autoFitColumns(); | |
//Save the result in XLSX format | |
book.save(SD_PATH + "outputCustomLabelsForSubtotals.xlsx"); | |
Log.w(TAG, "outputCustomLabelsForSubtotals.xlsx created successfully"); | |
} catch (Exception ex) { | |
Log.e(TAG, "Some exception occurred in UsingGlobalizationSettingsClassForCustomLabelsForSubtotals"); | |
Log.e(TAG, "Exception: " + ex.getMessage()); | |
Log.e(TAG, "StackTrace: " + Log.getStackTraceString(ex)); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
public class CustomSettings extends GlobalizationSettings | |
{ | |
//This function will return the sub total name | |
public String getTotalName(int functionType) | |
{ | |
return "Chinese Total - 可能的用法"; | |
} | |
//This function will return the grand total name | |
public String getGrandTotalName(int functionType) | |
{ | |
return "Chinese Grand Total - 可能的用法"; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
public class CustomSettings extends GlobalizationSettings | |
{ | |
public String getOtherName() | |
{ | |
String language = Locale.getDefault().getLanguage(); | |
System.out.println(language); | |
switch (language) | |
{ | |
case "en": | |
return "Other"; | |
case "fr": | |
return "Autre"; | |
case "de": | |
return "Andere"; | |
//Do other cases | |
default: | |
return super.getOtherName(); | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
//Loads an existing spreadsheet containing a pie chart | |
Workbook book = new Workbook(SD_PATH + "sample.xlsx"); | |
//Assigns the GlobalizationSettings property of the WorkbookSettings class | |
//to the class created in first step | |
book.getSettings().setGlobalizationSettings(new CustomSettings()); | |
//Accesses the 1st worksheet from the collection which contains pie chart | |
Worksheet sheet = book.getWorksheets().get(0); | |
//Accesses the 1st chart from the collection | |
Chart chart = sheet.getCharts().get(0); | |
//Refreshes the chart | |
chart.calculate(); | |
//Renders the chart to image | |
chart.toImage(SD_PATH + "output.png", new ImageOrPrintOptions()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Instantiating a Workbook object | |
Workbook workbook = new Workbook(); | |
//Obtaining the reference of the first worksheet. | |
WorksheetCollection worksheets = workbook.getWorksheets(); | |
Worksheet sheet = worksheets.get(0); | |
//Setting a value to the "A1" cell | |
Cells cells = sheet.getCells(); | |
Cell cell = cells.get("A1"); | |
cell.setValue("Visit Aspose"); | |
//Setting the font color of the cell to Blue | |
Style style = cell.getStyle(); | |
style.getFont().setColor(Color.getBlue()); | |
//Setting the font of the cell to Single Underline | |
style.getFont().setUnderline(FontUnderlineType.SINGLE); | |
cell.setStyle(style); | |
HyperlinkCollection hyperlinks = sheet.getHyperlinks(); | |
//Adding a link to the external file | |
hyperlinks.add("A5", 1, 1, filePath + File.separator + "Book1.xls"); | |
//Saving the Excel file | |
workbook.save(filePath + File.separator + "AddALinkToAnExternalFile_Out.xls"); | |
} catch (Exception e) { | |
Log.e(TAG, "Add a Link to an External File", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Instantiating a Workbook object | |
Workbook workbook = new Workbook(); | |
//Obtaining the reference of the first worksheet. | |
WorksheetCollection worksheets = workbook.getWorksheets(); | |
Worksheet sheet = worksheets.get(0); | |
//Setting a value to the "A1" cell | |
Cells cells = sheet.getCells(); | |
Cell cell = cells.get("A1"); | |
cell.setValue("Visit Aspose"); | |
//Setting the font color of the cell to Blue | |
Style style = cell.getStyle(); | |
style.getFont().setColor(Color.getBlue()); | |
//Setting the font of the cell to Single Underline | |
style.getFont().setUnderline(FontUnderlineType.SINGLE); | |
cell.setStyle(style); | |
HyperlinkCollection hyperlinks = sheet.getHyperlinks(); | |
//Adding an internal hyperlink to the "B9" cell of the other worksheet "Sheet2" in | |
//the same Excel file | |
hyperlinks.add("B3", 1, 1, "Sheet2!B9"); | |
//Saving the Excel file | |
workbook.save(filePath + File.separator + "AddALinkToAnotherCellInTheSameFile_Out.xls"); | |
} catch (Exception e) { | |
Log.e(TAG, "Add a Link to Another Cell in the Same File", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Instantiating a Workbook object | |
Workbook workbook = new Workbook(); | |
//Obtaining the reference of the first worksheet. | |
WorksheetCollection worksheets = workbook.getWorksheets(); | |
Worksheet sheet = worksheets.get(0); | |
HyperlinkCollection hyperlinks = sheet.getHyperlinks(); | |
//Adding a hyperlink to a URL at "A1" cell | |
hyperlinks.add("A1", 1, 1, "http://www.aspose.com"); | |
//Saving the Excel file | |
workbook.save(filePath + File.separator + "AddAURLLink_Out.xls"); | |
} catch (Exception e) { | |
Log.e(TAG, "Add a URL Link", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Instantiating a Workbook object | |
Workbook workbook = new Workbook(); | |
//Obtaining the reference of the first worksheet. | |
WorksheetCollection worksheets = workbook.getWorksheets(); | |
Worksheet sheet = worksheets.get(0); | |
//Setting a value to the "A1" cell | |
Cells cells = sheet.getCells(); | |
Cell cell = cells.get("A1"); | |
cell.setValue("Visit Aspose"); | |
//Setting the font color of the cell to Blue | |
Style style = cell.getStyle(); | |
style.getFont().setColor(Color.getBlue()); | |
//Setting the font of the cell to Single Underline | |
style.getFont().setUnderline(FontUnderlineType.SINGLE); | |
cell.setStyle(style); | |
HyperlinkCollection hyperlinks = sheet.getHyperlinks(); | |
//Adding a hyperlink to a URL at "A1" cell | |
hyperlinks.add("A1", 1, 1, "http://www.aspose.com"); | |
//Saving the Excel file | |
workbook.save(filePath + File.separator + "ApplyFormattingLikeHyperlink_Out.xls"); | |
} catch (Exception e) { | |
Log.e(TAG, "Apply Formatting to look like Hyperlink", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Create a Workbook. | |
Workbook wbk = new Workbook(); | |
//Create a Worksheet and get the first sheet. | |
Worksheet worksheet = wbk.getWorksheets().get(0); | |
//Create a Cells object to fetch all the cells. | |
Cells cells = worksheet.getCells(); | |
//Merge some Cells (C6:E7) into a single C6 Cell. | |
cells.merge(5, 2, 7, 4); | |
//Input data into C6 Cell. | |
worksheet.getCells().get("C6").setValue("This is my value"); | |
//Create a Style object to fetch the Style of C6 Cell. | |
Style style = worksheet.getCells().get("C6").getStyle(); | |
//Create a Font object | |
Font font = style.getFont(); | |
//Set the name. | |
font.setName("Times New Roman"); | |
//Set the font size. | |
font.setSize(18); | |
//Set the font color | |
font.setColor(Color.getBlue()); | |
//Bold the text | |
font.setBold(true); | |
//Make it italic | |
font.setItalic(true); | |
//Set the backgrond color of C6 Cell to Red | |
style.setBackgroundColor(Color.getRed()); | |
style.setPattern(BackgroundType.SOLID); | |
//Apply the Style to C6 Cell. | |
cells.get("C6").setStyle(style); | |
//Save the Workbook. | |
wbk.save(filePath + File.separator + "MergeCells_Out.xls"); | |
} catch (Exception e) { | |
Log.e(TAG, "Merge Cells in a Worksheet", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Create a Workbook. | |
Workbook wbk = new Workbook(filePath + File.separator + "mergingcells.xls"); | |
//Create a Worksheet and get the first sheet. | |
Worksheet worksheet = wbk.getWorksheets().get(0); | |
//Create a Cells object to fetch all the cells. | |
Cells cells = worksheet.getCells(); | |
//Unmerge the cells. | |
cells.unMerge(5, 2, 7, 4); | |
//Save the file. | |
wbk.save(filePath + File.separator + "UnmergeCells.xls"); | |
} catch (Exception e) { | |
Log.e(TAG, "Unmerge Merged Cells", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Instantiating a Workbook object | |
Workbook workbook = new Workbook(filePath + File.separator + "Book1.xls"); | |
WorksheetCollection worksheets = workbook.getWorksheets(); | |
//Getting all named ranges | |
Range[] namedRanges = worksheets.getNamedRanges(); | |
} catch (Exception e) { | |
Log.e(TAG, "Accessing All Named Ranges in a File", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Instantiating a Workbook object | |
Workbook workbook = new Workbook(filePath + File.separator + "Book1.xls"); | |
WorksheetCollection worksheets = workbook.getWorksheets(); | |
//Getting the specified named range | |
Range namedRange = worksheets.getRangeByName("TestRange"); | |
} catch (Exception e) { | |
Log.e(TAG, "Accessing a Specific Named Range", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Instantiating a Workbook object | |
Workbook workbook = new Workbook(); | |
//Adding a new worksheet to the Workbook object | |
//Obtaining the reference of the newly added worksheet | |
int sheetIndex = workbook.getWorksheets().add(); | |
Worksheet worksheet = workbook.getWorksheets().get(sheetIndex); | |
//Accessing the "A1" cell from the worksheet | |
Cell cell = worksheet.getCells().get("A1"); | |
//Adding some value to the "A1" cell | |
cell.setValue("Hello World From Aspose"); | |
//Creating a range of cells starting from "A1" cell to 3rd column in a row | |
Range range = worksheet.getCells().createRange(0,0,0,2); | |
range.setName("MyRange"); | |
//Adding a thick outline border with the blue line | |
range.setOutlineBorders(CellBorderType.THICK, Color.getBlue()); | |
//Saving the Excel file | |
workbook.save(filePath + File.separator + "AddBordersToANamedRange_Out.xls"); | |
} catch (Exception e) { | |
Log.e(TAG, "Add Borders to a Named Range", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Instantiating a Workbook object | |
Workbook workbook = new Workbook(); | |
//Obtaining the reference of the newly added worksheet | |
int sheetIndex = workbook.getWorksheets().add(); | |
Worksheet worksheet = workbook.getWorksheets().get(sheetIndex); | |
//Accessing the "A1" cell from the worksheet | |
Cell cell = worksheet.getCells().get("A1"); | |
//Adding some value to the "A1" cell | |
cell.setValue("Hello World!"); | |
//Creating a range of cells based on cells Address. | |
Range range = worksheet.getCells().createRange("A1:F10"); | |
//Specify a Style object for borders. | |
Style style = cell.getStyle(); | |
//Setting the line style of the top border | |
style.setBorder(BorderType.TOP_BORDER, CellBorderType.THICK, Color.getBlack()); | |
style.setBorder(BorderType.BOTTOM_BORDER,CellBorderType.THICK, Color.getBlack()); | |
style.setBorder(BorderType.LEFT_BORDER,CellBorderType.THICK, Color.getBlack()); | |
style.setBorder(BorderType.RIGHT_BORDER,CellBorderType.THICK, Color.getBlack()); | |
Iterator cellArray = range.iterator(); | |
while(cellArray.hasNext()) | |
{ | |
Cell temp = (Cell)cellArray.next(); | |
//Saving the modified style to the cell. | |
temp.setStyle(style); | |
} | |
//Saving the Excel file | |
workbook.save(filePath + File.separator + "ConvertCellsAddressToRangeOrCellArea_Out.xls"); | |
} catch (Exception e) { | |
Log.e(TAG, "Convert Cells Address to Range or CellArea", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Instantiating a Workbook object | |
Workbook workbook = new Workbook(); | |
WorksheetCollection worksheets = workbook.getWorksheets(); | |
//Accessing the first worksheet in the Excel file | |
Worksheet sheet = worksheets.get(0); | |
Cells cells = sheet.getCells(); | |
//Creating a named range | |
Range namedRange = cells.createRange("B4", "G14"); | |
namedRange.setName("TestRange"); | |
//Saving the modified Excel file in default (that is Excel 2000) format | |
workbook.save(filePath + File.separator + "CreateANamedRange_Out.xls"); | |
} catch (Exception e) { | |
Log.e(TAG, "Create a Named Range", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Instantiate a new Workbook. | |
Workbook workbook = new Workbook(); | |
//Get the first worksheet in the workbook. | |
Worksheet worksheet1 = workbook.getWorksheets().get(0); | |
//Create a range of cells and specify its name based on H1:J4. | |
Range range = worksheet1.getCells().createRange(0, 7, 3, 9); | |
range.setName("MyRange"); | |
//Input some data into cells in the range. | |
range.get(0, 0).setValue("USA"); | |
range.get(0, 1).setValue("SA"); | |
range.get(0, 2).setValue("Israel"); | |
range.get(1, 0).setValue("UK"); | |
range.get(1, 1).setValue("AUS"); | |
range.get(1, 2).setValue("Canada"); | |
range.get(2, 0).setValue("France"); | |
range.get(2, 1).setValue("India"); | |
range.get(2, 2).setValue("Egypt"); | |
range.get(3, 0).setValue("China"); | |
range.get(3, 1).setValue("Philipine"); | |
range.get(3, 2).setValue("Brazil"); | |
//Identify range cells. | |
int firstrow = range.getFirstRow(); | |
int firstcol = range.getFirstColumn(); | |
int trows = range.getRowCount(); | |
int tcols = range.getColumnCount(); | |
//Save the excel file. | |
workbook.save(filePath + File.separator + "RangeCells_Out.xls"); | |
} catch (Exception e) { | |
Log.e(TAG, "Input Data into a Named Range", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
//Create an instance of Workbook | |
Workbook book = new Workbook(); | |
//Get the WorksheetCollection | |
WorksheetCollection worksheets = book.getWorksheets(); | |
//Add a new Named Range with name "data" | |
int index = worksheets.getNames().add("data"); | |
//Access the newly created Named Range from the collection | |
Name data = worksheets.getNames().get(index); | |
//Set RefersTo property of the Named Range to a cell range in same worksheet | |
data.setRefersTo("=Sheet1!$A$1:$A$10"); | |
//Add another Named Range with name "range" | |
index = worksheets.getNames().add("range"); | |
//Access the newly created Named Range from the collection | |
Name range = worksheets.getNames().get(index); | |
//Set RefersTo property to a formula using the Named Range data | |
range.setRefersTo("=INDEX(data,Sheet1!$A$1,1):INDEX(data,Sheet1!$A$1,9)"); | |
} catch (Exception e) { | |
Log.e(TAG, "Set a Complex Formula for Named Range", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Create an instance of Workbook | |
Workbook book = new Workbook(); | |
//Get the WorksheetCollection | |
WorksheetCollection worksheets = book.getWorksheets(); | |
//Add a new Named Range with name "myName" | |
int index = worksheets.getNames().add("myName"); | |
//Access the newly created Named Range | |
Name name = worksheets.getNames().get(index); | |
//Set RefersTo property of the Named Range to a formula | |
//Formula references another cell in the same worksheet | |
name.setRefersTo("=Sheet1!$A$3"); | |
//Set the formula in the cell A1 to the newly created Named Range | |
worksheets.get(0).getCells().get("A1").setFormula("myName"); | |
//Insert the value in cell A3 which is being referenced in the Named Range | |
worksheets.get(0).getCells().get("A3").putValue("This is the value of A3"); | |
//Calculate formulas | |
book.calculateFormula(); | |
//Save the result in XLSX format | |
book.save(filePath + File.separator + "SetASimpleFormulaForNamedRange_Out.xlsx"); | |
} catch (Exception e) { | |
Log.e(TAG, "Set a Simple Formula for Named Range", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Instantiate a new Workbook. | |
Workbook workbook = new Workbook(); | |
//Get the first worksheet in the book. | |
Worksheet WS = workbook.getWorksheets().get(0); | |
//Create a named range of cells. | |
com.aspose.cells.Range range = WS.getCells().createRange(1, 1, 1, 17); | |
range.setName("MyRange"); | |
//Declare a style object. | |
Style stl; | |
//Create the style object with respect to the style of a cell. | |
stl = WS.getCells().getCell(1, 1).getStyle(); | |
//Specify some Font settings. | |
stl.getFont().setName("Arial"); | |
stl.getFont().setBold(true); | |
//Set the font text color | |
stl.getFont().setColor(Color.getRed()); | |
//To Set the fill color of the range, you may use ForegroundColor with | |
//solid Pattern setting. | |
stl.setBackgroundColor(Color.getYellow()); | |
stl.setPattern(BackgroundType.SOLID); | |
//Apply the style to the range. | |
for (int r = 1; r < 2; r++) { | |
for (int c = 1; c < 18; c++) { | |
WS.getCells().getCell(r, c).setStyle(stl); | |
} | |
} | |
//Save the Excel file. | |
workbook.save(filePath + File.separator + "BackgroundColorAndFontAttributes_Out.xls"); | |
} catch (Exception e) { | |
Log.e(TAG, "Set Background Color and Font Attributes", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Create an instance of Workbook | |
Workbook book = new Workbook(); | |
//Get the WorksheetCollection | |
WorksheetCollection worksheets = book.getWorksheets(); | |
//Insert some data in cell A1 of Sheet1 | |
worksheets.get("Sheet1").getCells().get("A1").putValue(10); | |
//Add a new Worksheet and insert a value to cell A1 | |
worksheets.get(worksheets.add()).getCells().get("A1").putValue(10); | |
//Add a new Named Range with name "range" | |
int index = worksheets.getNames().add("range"); | |
//Access the newly created Named Range from the collection | |
Name range = worksheets.getNames().get(index); | |
//Set RefersTo property of the Named Range to a SUM function | |
range.setRefersTo("=SUM(Sheet1!$A$1,Sheet2!$A$1)"); | |
//Insert the Named Range as formula to 3rd worksheet | |
worksheets.get(worksheets.add()).getCells().get("A1").setFormula("range"); | |
//Calculate formulas | |
book.calculateFormula(); | |
//Save the result in XLSX format | |
book.save(filePath + File.separator + "SumValueFrom2Cells_Out.xlsx"); | |
} catch (Exception e) { | |
Log.e(TAG, "Use a named range to sum values from 2 cells in different worksheets", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Instantiate a workbook from source file | |
Workbook workbook = new Workbook(filePath + File.separator + "Book1.xlsx"); | |
//Access the first workbook | |
Worksheet worksheet = workbook.getWorksheets().get(0); | |
//Access the Maximum Display Range | |
Range range = worksheet.getCells().getMaxDisplayRange(); | |
//Print the Maximum Display Range RefersTo property | |
Log.v(TAG, "Maximum Display Range: " + range.getRefersTo()); | |
} catch (Exception e) { | |
Log.e(TAG, "Access a Worksheet's Maximum Display Range", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Instantiating a Workbook object | |
Workbook workbook = new Workbook(); | |
//Accessing the added worksheet in the Excel file | |
int sheetIndex = workbook.getWorksheets().add(); | |
Worksheet worksheet = workbook.getWorksheets().get(sheetIndex); | |
Cells cells = worksheet.getCells(); | |
//Accessing a cell using its name | |
Cell cell = cells.get("A1"); | |
} catch (Exception e) { | |
Log.e(TAG, "Access Using Cell Name", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
Workbook workbook = new Workbook(); | |
int sheetIndex = workbook.getWorksheets().add(); | |
Worksheet worksheet = workbook.getWorksheets().get(sheetIndex); | |
Cells cells = worksheet.getCells(); | |
//Adding a string value to the cell | |
Cell cell = cells.get("A1"); | |
cell.setValue("Hello World"); | |
//Adding a double value to the cell | |
cell = cells.get("A2"); | |
cell.setValue(20.5); | |
//Adding an integer value to the cell | |
cell = cells.get("A3"); | |
cell.setValue(15); | |
//Adding a boolean value to the cell | |
cell = cells.get("A4"); | |
cell.setValue(true); | |
//Adding a date/time value to the cell | |
cell = cells.get("A5"); | |
DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss"); | |
Date date = new Date(); | |
cell.setValue(dateFormat.format(date)); | |
//Setting the display format of the date | |
Style style = cell.getStyle(); | |
style.setNumber(15); | |
cell.setStyle(style); | |
//Saving the Excel file | |
workbook.save(filePath + File.separator + "AddDataToCells_Out.xls"); | |
} catch (Exception e) { | |
Log.e(TAG, "Add Data to Cells", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Instantiate a new Workbook object. | |
Workbook workbook = new Workbook(filePath + File.separator + "Book1.xls"); | |
//Get the workbook data sorter object. | |
DataSorter sorter = workbook.getDataSorter(); | |
//Set the first order for data sorter object. | |
sorter.setOrder1(SortOrder.DESCENDING); | |
//Define the first key. | |
sorter.setKey1(0); | |
//Set the second order for data sorter object. | |
sorter.setOrder2(SortOrder.ASCENDING); | |
//Define the second key. | |
sorter.setKey2(1); | |
//Sort data in the specified data range (CellArea range: A1:B14) | |
CellArea cellArea = new CellArea(); | |
cellArea.StartRow = 0; | |
cellArea.StartColumn = 0; | |
cellArea.EndRow = 13; | |
cellArea.EndColumn = 1; | |
sorter.sort(workbook.getWorksheets().get(0).getCells(), cellArea); | |
//Save the excel file. | |
workbook.save(filePath + File.separator + "DataSorting_Out.xls"); | |
} catch (Exception e) { | |
Log.e(TAG, "Data Sorting", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Creating a file stream containing the Excel file to be opened | |
FileInputStream fstream = new FileInputStream(filePath + File.separator + "Book1.xls"); | |
//Instantiating a Workbook object | |
Workbook workbook = new Workbook(fstream); | |
//Accessing the first worksheet in the Excel file | |
Worksheet worksheet = workbook.getWorksheets().get(0); | |
//Exporting the contents of 7 rows and 2 columns starting from 1st cell to Array. | |
Object dataTable [][] = worksheet.getCells().exportArray(0, 0, 7, 2); | |
//Closing the file stream to free all resources | |
fstream.close(); | |
} catch (Exception e) { | |
Log.e(TAG, "Export Data to Array", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Instantiating a Workbook object | |
Workbook workbook = new Workbook(filePath + File.separator + "Book1.xls"); | |
//Accessing the first worksheet in the Excel file | |
Worksheet worksheet = workbook.getWorksheets().get(0); | |
//Finding the cell containing the specified formula | |
Cells cells = worksheet.getCells(); | |
FindOptions findOptions = new FindOptions(); | |
findOptions.setLookInType(LookInType.FORMULAS); | |
Cell cell = cells.find("=SUM(A2:A5)", null, findOptions); | |
//Printing the name of the cell found after searching worksheet | |
if(cell != null) { | |
Log.v(TAG, "Name of the cell containing formula: " + cell.getName()); | |
} | |
} catch (Exception e) { | |
Log.e(TAG, "Find Cells that Contain a Formula", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Instantiating a Workbook object | |
Workbook workbook = new Workbook(filePath + File.separator + "Book1.xls"); | |
//Accessing the first worksheet in the Excel file | |
Worksheet worksheet = workbook.getWorksheets().get(0); | |
//Finding the cell containing a string value that ends with "es" | |
Cells cells = worksheet.getCells(); | |
FindOptions findOptions = new FindOptions(); | |
findOptions.setLookAtType(LookAtType.END_WITH); | |
Cell cell = cells.find("es", null, findOptions); | |
//Printing the name of the cell found after searching worksheet | |
if(cell != null) { | |
Log.v(TAG, cell.getName()); | |
} | |
} catch (Exception e) { | |
Log.e(TAG, "Searching for Strings that End with Specific Characters", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Instantiating a Workbook object | |
Workbook workbook = new Workbook(filePath + File.separator + "Book1.xls"); | |
//Accessing the first worksheet in the Excel file | |
Worksheet worksheet = workbook.getWorksheets().get(0); | |
//Finding the cell containing a string value that starts with "Or" | |
Cells cells = worksheet.getCells(); | |
FindOptions findOptions = new FindOptions(); | |
findOptions.setLookAtType(LookAtType.START_WITH); | |
Cell cell = cells.find("Or", null, findOptions); | |
//Printing the name of the cell found after searching worksheet | |
if(cell != null) { | |
Log.v(TAG, cell.getName()); | |
} | |
} catch (Exception e) { | |
Log.e(TAG, "Searching for Strings that Start with Specific Characters", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Instantiating a Workbook object | |
Workbook workbook = new Workbook(filePath + File.separator + "Book1.xls"); | |
//Accessing the first worksheet in the Excel file | |
Worksheet worksheet = workbook.getWorksheets().get(0); | |
//Finding the cell with a formula that contains an input string | |
Cells cells = worksheet.getCells(); | |
FindOptions findOptions = new FindOptions(); | |
findOptions.setLookAtType(LookAtType.CONTAINS); | |
Cell cell = cells.find("SUM", null, findOptions); | |
//Printing the name of the cell found after searching worksheet | |
if(cell != null) { | |
Log.v(TAG, cell.getName()); | |
} | |
} catch (Exception e) { | |
Log.e(TAG, "Search with Partial Formula", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Instantiating a Workbook object | |
Workbook workbook = new Workbook(filePath + File.separator + "Book1.xls"); | |
//Accessing the first worksheet in the Excel file | |
Worksheet worksheet = workbook.getWorksheets().get(0); | |
Cells cells = worksheet.getCells(); | |
FindOptions opt = new FindOptions(); | |
//Set the search key of find() method as standard RegEx | |
opt.setRegexKey(true); | |
opt.setLookAtType(LookAtType.ENTIRE_CONTENT); | |
Cell cell = cells.find("abc[\\s]*$", null, opt); | |
//Printing the name of the cell found after searching worksheet | |
if(cell != null) { | |
Log.v(TAG, cell.getName()); | |
} | |
} catch (Exception e) { | |
Log.e(TAG, "Searching with Regular Expressions", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Instantiating a Workbook object | |
Workbook workbook = new Workbook(); | |
//Obtaining the reference of the newly added worksheet by passing its sheet index | |
int sheetIndex = workbook.getWorksheets().add(); | |
Worksheet worksheet= workbook.getWorksheets().get(sheetIndex); | |
//Creating an array containing names as string values | |
String[] names=new String[]{"laurence chen", "roman korchagin", "kyle huang"}; | |
//Importing the array of names to 1st row and first column vertically | |
Cells cells = worksheet.getCells(); | |
cells.importArray(names, 0, 0, false); | |
//Saving the Excel file | |
workbook.save(filePath + File.separator + "ImportFromArray_Out.xlsx"); | |
} catch (Exception e) { | |
Log.e(TAG, "Import From Array", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Instantiate a new Workbook | |
Workbook workbook = new Workbook(); | |
//Get the first worksheet (default sheet) in the Workbook | |
Cells cells = workbook.getWorksheets().get("Sheet1").getCells(); | |
//Instantiating an ArrayList object | |
ArrayList<String> list = new ArrayList(); | |
list.add("laurence chen"); | |
list.add("roman korchagin"); | |
list.add("kyle huang"); | |
list.add("tommy wang"); | |
//Importing the contents of ArrayList to 1st row and first column vertically | |
cells.importArrayList(list, 0, 0, true); | |
//Save the Excel file | |
workbook.save(filePath + File.separator + "ImportFromArrayList_Out.xlsx"); | |
} catch (Exception e) { | |
Log.e(TAG, "Import from ArrayList", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Instantiate a new Workbook | |
Workbook workbook = new Workbook(); | |
//Get the first worksheet (default sheet) in the Workbook | |
Cells cells = workbook.getWorksheets().get("Sheet1").getCells(); | |
//Define a multi-dimensional array and store some data into it. | |
String[][] strArray = { | |
{"A", "1A","2A" }, | |
{"B", "2B", "3B"} | |
}; | |
//Import the multi-dimensional array to the sheet | |
cells.importArray(strArray, 0, 0); | |
//Save the Excel file | |
workbook.save(filePath + File.separator + "ImportFromMultiDimArray_Out.xlsx"); | |
} catch (Exception e) { | |
Log.e(TAG, "Import from Multi-dimensional Array", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Create a new Workbook. | |
Workbook workbook =new Workbook(); | |
Class.forName("net.ucanaccess.jdbc.UcanaccessDriver"); | |
String connectionString = "jdbc:ucanaccess://" + filePath + File.separator + "Northwind.mdb"; | |
// DSN-less DB connection. | |
Connection connection = DriverManager.getConnection(connectionString); | |
Statement statement = connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); | |
//Get the ResultSet executing the SQL statement. | |
ResultSet rs = statement.executeQuery("select EmployeeID, LastName, FirstName, Title, City from Employees"); | |
//Fetch the first worksheet. | |
Worksheet worksheet = workbook.getWorksheets().get(0); | |
//Import the ResultSet to the worksheet. | |
worksheet.getCells().importResultSet(rs,"A1",true); | |
//Save the excel file. | |
workbook.save(filePath + File.separator + "ImportFromResultSet.xls"); | |
} catch (Exception e) { | |
Log.e(TAG, "Import from ResultSet", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Open a template Excel file | |
Workbook workbook = new Workbook(filePath + File.separator + "Book1.xlsx"); | |
//Get the first worksheet (default worksheet) | |
Worksheet worksheet = workbook.getWorksheets().get(0); | |
//Get the A1 cell | |
Cell c = worksheet.getCells().get("A1"); | |
//Get the all the Dependents of A1 cell | |
Cell[] dependents = c.getDependents(true); | |
for (int i = 0; i< dependents.length; i++) { | |
Log.v(TAG, dependents[i].getWorksheet().getName() + "----" + dependents[i].getName() + ":" + dependents[i].getIntValue()); | |
} | |
} catch (Exception e) { | |
Log.e(TAG, "Trace Dependents", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Instantiating a Workbook object | |
Workbook workbook = new Workbook(filePath + File.separator + "Book1.xls"); | |
Cells cells = workbook.getWorksheets().get(0).getCells(); | |
Cell cell = cells.get("B7"); | |
//Tracing precedents of the cell B7. | |
//The return array contains ranges and cells. | |
ReferredAreaCollection ret = cell.getPrecedents(); | |
//Printing all the precedent cells' name. | |
if(ret != null) { | |
for(int m = 0 ; m < ret.getCount(); m++) { | |
ReferredArea area = ret.get(m); | |
StringBuilder stringBuilder = new StringBuilder(); | |
if (area.isExternalLink()) { | |
stringBuilder.append("["); | |
stringBuilder.append(area.getExternalFileName()); | |
stringBuilder.append("]"); | |
} | |
stringBuilder.append(area.getSheetName()); | |
stringBuilder.append("!"); | |
stringBuilder.append(CellsHelper.cellIndexToName(area.getStartRow(), area.getStartColumn())); | |
if (area.isArea()) { | |
stringBuilder.append(":"); | |
stringBuilder.append(CellsHelper.cellIndexToName(area.getEndRow(), area.getEndColumn())); | |
} | |
Log.v(TAG, stringBuilder.toString()); | |
} | |
} | |
} catch (Exception e) { | |
Log.e(TAG, "Trace Precedent", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Instantiate a new workbook | |
Workbook workbook = new Workbook(filePath + File.separator + "Book1.xls"); | |
//Get the Cells collection in the first worksheet | |
Cells cells = workbook.getWorksheets().get(0).getCells(); | |
//Create a cellarea i.e.., B3:C19 | |
CellArea ca = new CellArea(); | |
ca.StartRow = 2; | |
ca.StartColumn = 1; | |
ca.EndRow = 18; | |
ca.EndColumn = 2; | |
//Apply subtotal, the consolidation function is Sum and it will applied to | |
//Second column (C) in the list | |
cells.subtotal(ca, 0, ConsolidationFunction.SUM, new int[]{1}); | |
//Save the Excel file | |
workbook.save(filePath + File.separator + "CreatingSubtotals_Out.xls"); | |
} catch (Exception e) { | |
Log.e(TAG, "Creating Subtotals", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Instantiating a Workbook object | |
Workbook workbook = new Workbook(filePath + File.separator + "Book1.xls"); | |
//Accessing the first worksheet in the Excel file | |
Worksheet worksheet = workbook.getWorksheets().get(0); | |
//Creating AutoFilter by giving the cells range | |
AutoFilter autoFilter = worksheet.getAutoFilter(); | |
CellArea area = new CellArea(); | |
autoFilter.setRange("A1:B4"); | |
//Saving the modified Excel file | |
workbook.save(filePath + File.separator + "Autofilter_Out.xls"); | |
} catch (Exception e) { | |
Log.e(TAG, "Auto Filter", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Instantiating a Workbook object | |
Workbook workbook = new Workbook(filePath + File.separator + "Book1.xls"); | |
//Accessing the first worksheet in the Excel file | |
Worksheet worksheet = workbook.getWorksheets().get(0); | |
//Obtaining the auto-filters in the worksheet | |
AutoFilter autoFilter = worksheet.getAutoFilter(); | |
autoFilter.addFilter(0, "6"); | |
autoFilter.addFilter(0, "7"); | |
autoFilter.addFilter(0, "10"); | |
//Saving the modified Excel file | |
workbook.save(filePath + File.separator + "AutoFilterOptions_Out.xls"); | |
} catch (Exception e) { | |
Log.e(TAG, "Advanced Auto-Filter Options", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Creating an instance of Workbook | |
Workbook workbook = new Workbook(); | |
//Accessing the cells of the first worksheet | |
Cells cells = workbook.getWorksheets().get(0).getCells(); | |
//Putting a string value into the A1 cell | |
cells.get("A1").putValue("Please enter Date between 1/1/1970 and 12/31/1999"); | |
//Wrapping the text | |
cells.get("A1").getStyle().setTextWrapped(true); | |
//Setting row height and column width for the cells | |
cells.setRowHeight(0, 31); | |
cells.setColumnWidth(0, 35); | |
//Getting the validations collection | |
ValidationCollection validations = workbook.getWorksheets().get(0).getValidations(); | |
//Setting the CellArea on which the data validation rule will be applied | |
CellArea area = CellArea.createCellArea(0, 1, 0, 1); | |
//Adding a new validation to the collection | |
int index = validations.add(area); | |
Validation validation = validations.get(index); | |
//Setting the data validation type | |
validation.setType(ValidationType.DATE); | |
//Setting the operator for the data validation | |
validation.setOperator(OperatorType.BETWEEN); | |
//Setting the value or expression associated with the data validation | |
validation.setFormula1("1/1/1970"); | |
//Setting value or expression associated with the second part of the data validation | |
validation.setFormula2("12/31/1999"); | |
//Enabling the error | |
validation.setShowError(true); | |
//Setting the validation alert style | |
validation.setAlertStyle(ValidationAlertType.STOP); | |
//Setting the title of the data validation error dialog box | |
validation.setErrorTitle("Date Error"); | |
//Setting the data validation error message | |
validation.setErrorMessage("Enter a Valid Date"); | |
//Setting and enabling the data validation input message | |
validation.setInputMessage("Date Validation Type"); | |
validation.setIgnoreBlank(true); | |
validation.setShowInput(true); | |
workbook.save(filePath + File.separator + "DateDataValidation_Out.xlsx"); | |
} catch (Exception e) { | |
Log.e(TAG, "Date Data Validation", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Creating an instance of Workbook | |
Workbook workbook = new Workbook(); | |
//Accessing the first worksheet in the collection | |
Worksheet worksheet = workbook.getWorksheets().get(0); | |
//Accessing the worksheet's validation collection | |
ValidationCollection validations = worksheet.getValidations(); | |
//Creating the CellArea structure on which validation has to be applied | |
CellArea area= new CellArea(); | |
area.StartRow = 0; | |
area.EndRow = 9; | |
area.StartColumn = 0; | |
area.EndColumn = 0; | |
//Creating a validation object by adding it to the collection | |
int index = validations.add(area); | |
Validation validation = validations.get(index); | |
//Setting the validation type to Decimal | |
validation.setType(ValidationType.DECIMAL); | |
//Specifying the operator type | |
validation.setOperator(OperatorType.BETWEEN); | |
//Setting the lower & upper limits | |
validation.setFormula1(new Double(Double.MIN_VALUE).toString()); | |
validation.setFormula2(new Double(Double.MAX_VALUE).toString()); | |
//Setting the error message | |
validation.setErrorMessage("Please enter a valid integer or decimal number"); | |
//Setting the number format to 2 decimal places for the validation area | |
for (int i = 0; i < 10; i++) { | |
worksheet.getCells().get(i, 0).getStyle().setCustom("0.00"); | |
} | |
workbook.save(filePath + File.separator + "DecimalDataValidation_Out.xlsx"); | |
} catch (Exception e) { | |
Log.e(TAG, "Decimal Data Validation", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Instantiating a Workbook object | |
Workbook workbook = new Workbook(filePath + File.separator + "Book1.xls"); | |
//Accessing the first worksheet in the Excel file | |
Worksheet worksheet = workbook.getWorksheets().get(0); | |
//Creating AutoFilter by giving the cells range | |
AutoFilter autoFilter = worksheet.getAutoFilter(); | |
autoFilter.setRange("A1:B4"); | |
//Filtering columns with specified values | |
autoFilter.filter(1, "Bananas"); | |
//Saving the modified Excel file | |
workbook.save(filePath + File.separator + "FilterColumns_Out.xls"); | |
} catch (Exception e) { | |
Log.e(TAG, "Filter Columns with Specified Values", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Creating an instance of Workbook | |
Workbook workbook = new Workbook(); | |
//Accessing the first worksheet from collection | |
Worksheet worksheet = workbook.getWorksheets().get(0); | |
//Creating a range in the worksheet | |
Range range = worksheet.getCells().createRange("E1", "E4"); | |
range.setName("MyRange"); | |
//Filling different cells with data in the range | |
range.get(0,0).setValue("Blue"); | |
range.get(1,0).setValue("Red"); | |
range.get(2,0).setValue("Green"); | |
range.get(3,0).setValue("Yellow"); | |
//Getting the validations collection | |
ValidationCollection validations = worksheet.getValidations(); | |
//Specifying the validation area | |
CellArea area = new CellArea(); | |
area.StartRow = 0; | |
area.StartColumn = 0; | |
area.EndRow = 4; | |
area.EndColumn = 0; | |
//Creating a new validation to the validation collection | |
int index = validations.add(area); | |
Validation validation = validations.get(index); | |
//Setting the validation type | |
validation.setType(ValidationType.LIST); | |
//Setting the in cell drop down | |
validation.setInCellDropDown(true); | |
//Setting the formula | |
validation.setFormula1("=MyRange"); | |
//Enabling it to show error | |
validation.setShowError(true); | |
//Setting the alert type severity level | |
validation.setAlertStyle(ValidationAlertType.STOP); | |
//Setting the error title | |
validation.setErrorTitle("Error"); | |
//Setting the error message | |
validation.setErrorMessage("Please select a color from the list"); | |
workbook.save(filePath + File.separator + "ListDataValidation_Out.xlsx"); | |
} catch (Exception e) { | |
Log.e(TAG, "List Data Validation", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Creating an instance of Workbook | |
Workbook workbook = new Workbook(); | |
//Accessing the cells of default worksheet | |
Cells cells = workbook.getWorksheets().get(0).getCells(); | |
//Inserting the help text in cell A1 | |
cells.get("A1").putValue("Please enter a string not more than 5 chars"); | |
//Wrapping the text of cell A1 | |
cells.get("A1").getStyle().setTextWrapped(true); | |
//Setting row height & column width | |
cells.setRowHeight(0, 31); | |
cells.setColumnWidth(0, 35); | |
//Accessing the validation collection of first worksheet | |
ValidationCollection validations = workbook.getWorksheets().get(0).getValidations(); | |
//Creating cell area on which validation has to be applied | |
CellArea area = CellArea.createCellArea(0, 1, 0, 1); | |
//Adding a new validation to the collection | |
int index = validations.add(area); | |
Validation validation = validations.get(index); | |
//Setting the data validation type | |
validation.setType(ValidationType.TEXT_LENGTH); | |
//Setting the operator for the data validation | |
validation.setOperator(OperatorType.LESS_OR_EQUAL); | |
//Setting the value or expression associated with the data validation | |
validation.setFormula1("5"); | |
//Enabling the error | |
validation.setShowError(true); | |
//Setting the validation alert style | |
validation.setAlertStyle(ValidationAlertType.WARNING); | |
//Setting the title of the data-validation error dialog box | |
validation.setErrorTitle("Text Length Error"); | |
//Setting the data validation error message | |
validation.setErrorMessage(" Enter a Valid String"); | |
//Setting and enabling the data validation input message | |
validation.setInputMessage("TextLength Validation Type"); | |
validation.setIgnoreBlank(true); | |
validation.setShowInput(true); | |
workbook.save(filePath + File.separator + "TextLengthDataValidation_Out.xlsx"); | |
} catch (Exception e) { | |
Log.e(TAG, "Text Length Data Validation", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Creating an instance of Workbook | |
Workbook workbook = new Workbook(); | |
//Accessing the cells of the first worksheet | |
Cells cells = workbook.getWorksheets().get(0).getCells(); | |
//Putting a string value into the A1 cell | |
cells.get("A1").setValue("Please enter Time b/w 09:00 and 11:30 'o Clock"); | |
//Wrapping the text | |
cells.get("A1").getStyle().setTextWrapped(true); | |
//Setting row height and column width for the cells | |
cells.setRowHeight(0, 31); | |
cells.setColumnWidth(0, 35); | |
//Getting the validations collection | |
ValidationCollection validations = workbook.getWorksheets().get(0).getValidations(); | |
//Setting the CellArea on which the data validation rule will be applied | |
CellArea area = CellArea.createCellArea(0, 1, 0, 1); | |
//Adding a new validation to the collection | |
int index = validations.add(area); | |
Validation validation = validations.get(index); | |
//Setting the data validation type | |
validation.setType(ValidationType.TIME); | |
//Setting the operator for the data validation | |
validation.setOperator(OperatorType.BETWEEN); | |
//Setting the value or expression associated with the data validation | |
validation.setFormula1("09:00"); | |
//Setting value or expression associated with the second part of the data validation | |
validation.setFormula2("11:30"); | |
//Enabling the error | |
validation.setShowError(true); | |
//Setting the validation alert style | |
validation.setAlertStyle(ValidationAlertType.STOP); | |
//Setting the title of the data validation error dialog box | |
validation.setErrorTitle("Time Error"); | |
//Setting the data validation error message | |
validation.setErrorMessage("Enter a Valid Time"); | |
//Setting and enabling the data validation input message | |
validation.setInputMessage("Time Validation Type"); | |
validation.setIgnoreBlank(true); | |
validation.setShowInput(true); | |
workbook.save(filePath + File.separator + "TimeDataValidation_Out.xlsx"); | |
} catch (Exception e) { | |
Log.e(TAG, "Time Data Validation", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Instantiating a Workbook object | |
Workbook workbook = new Workbook(); | |
WorksheetCollection worksheets = workbook.getWorksheets(); | |
//Accessing the Validations collection of the worksheet | |
Worksheet worksheet = worksheets.get(0); | |
ValidationCollection validations = worksheet.getValidations(); | |
//Creating the CellArea on which validation has to be applied | |
CellArea area = new CellArea(); | |
area.StartRow = 0; | |
area.StartColumn = 0; | |
area.EndRow = 1; | |
area.EndColumn = 1; | |
//Creating a Validation object | |
int index = validations.add(area); | |
Validation validation = validations.get(index); | |
//Setting the validation type to whole number | |
validation.setType(ValidationType.WHOLE_NUMBER); | |
//Setting the operator for validation to Between | |
validation.setOperator(OperatorType.BETWEEN); | |
//Setting the minimum value for the validation | |
validation.setFormula1("10"); | |
//Setting the maximum value for the validation | |
validation.setFormula2 ("1000"); | |
//Adding the cell area to Validation | |
validation.addArea(area); | |
//Saving the Excel file | |
workbook.save(filePath + File.separator + "WholeNumberDataValidation_Out.xlsx"); | |
} catch (Exception e) { | |
Log.e(TAG, "Whole Number Data Validation", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Instantiate a new Workbook. | |
Workbook workbook = new Workbook(); | |
//Get the first worksheet in the workbook. | |
Worksheet worksheet1 = workbook.getWorksheets().get(0); | |
//Get the cells in the worksheet. | |
Cells cells = worksheet1.getCells(); | |
//Input data into B2 cell. | |
cells.get("B2").setValue("Hello World!"); | |
//Set the first sheet as an active sheet. | |
workbook.getWorksheets().setActiveSheetIndex(0); | |
//Set B2 cell as an active cell in the worksheet. | |
worksheet1.setActiveCell("B2"); | |
//Set the B column as the first visible column in the worksheet. | |
worksheet1.setFirstVisibleColumn(1); | |
//Set the 2nd row as the first visible row in the worksheet. | |
worksheet1.setFirstVisibleRow(1); | |
//Save the excel file. | |
workbook.save(filePath + File.separator + "ActiveCell_Out.xls"); | |
} catch(Exception e) { | |
Log.e(TAG, "Activate Sheet and Make an Active Cell", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
//Instantiating a Workbook object | |
Workbook workbook = new Workbook(); | |
Worksheet sheet = workbook.getWorksheets().get(0); | |
ConditionalFormattingCollection cfs = sheet.getConditionalFormattings(); | |
// Adds an empty conditional formatting | |
int index = cfs.add(); | |
FormatConditionCollection fcs = cfs.get(index); | |
//Sets the conditional format range. | |
CellArea ca1 = new CellArea(); | |
ca1.StartRow = 0; | |
ca1.StartColumn = 0; | |
ca1.EndRow = 0; | |
ca1.EndColumn = 0; | |
CellArea ca2 = new CellArea(); | |
ca2.StartRow = 0; | |
ca2.StartColumn = 0; | |
ca2.EndRow = 0; | |
ca2.EndColumn = 0; | |
CellArea ca3 = new CellArea(); | |
ca3.StartRow = 0; | |
ca3.StartColumn = 0; | |
ca3.EndRow = 0; | |
ca3.EndColumn = 0; | |
fcs.addArea(ca1); | |
fcs.addArea(ca2); | |
fcs.addArea(ca3); | |
//Sets condition formulas. | |
int conditionIndex = fcs.addCondition(FormatConditionType.CELL_VALUE, OperatorType.BETWEEN,"=A2","100"); | |
FormatCondition fc = fcs.get(conditionIndex); | |
int conditionIndex2 = fcs.addCondition(FormatConditionType.CELL_VALUE,OperatorType.BETWEEN,"50","100"); | |
} catch(Exception e) { | |
Log.e(TAG, "Apply Conditional Formatting", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
//Instantiating a Workbook object | |
Workbook workbook = new Workbook(); | |
Worksheet sheet = workbook.getWorksheets().get(0); | |
ConditionalFormattingCollection cfs = sheet.getConditionalFormattings(); | |
// Adds an empty conditional formatting | |
int index = cfs.add(); | |
FormatConditionCollection fcs = cfs.get(index); | |
//Sets condition formulas. | |
int conditionIndex = fcs.addCondition(FormatConditionType.CELL_VALUE, OperatorType.BETWEEN,"=A2","100"); | |
FormatCondition fc = fcs.get(conditionIndex); | |
Style style = fc.getStyle(); | |
style.setBorder(BorderType.LEFT_BORDER, CellBorderType.DASHED,Color.fromArgb(0, 255, 255)); | |
style.setBorder(BorderType.TOP_BORDER,CellBorderType.DASHED,Color.fromArgb(0, 255, 255)) | |
style.setBorder(BorderType.RIGHT_BORDER,CellBorderType.DASHED,Color.fromArgb(0, 255, 255)); | |
style.setBorder(BorderType.RIGHT_BORDER,CellBorderType.DASHED,Color.fromArgb(255, 255, 0)); | |
fc.setStyle(style); | |
} catch(Exception e) { | |
Log.e(TAG, "Set Border", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
//Instantiating a Workbook object | |
Workbook workbook = new Workbook(); | |
Worksheet sheet = workbook.getWorksheets().get(0); | |
ConditionalFormattingCollection cfs = sheet.getConditionalFormattings(); | |
// Adds an empty conditional formatting | |
int index = cfs.add(); | |
FormatConditionCollection fcs = cfs.get(index); | |
//Sets condition formulas. | |
int conditionIndex = fcs.addCondition(FormatConditionType.CELL_VALUE, OperatorType.BETWEEN,"=A2","100"); | |
FormatCondition fc = fcs.get(conditionIndex); | |
Style style = fc.getStyle(); | |
Font font = style.getFont(); | |
font.setItalic(true); | |
font.setBold(true); | |
font.setStrikeout(true); | |
font.setUnderline(FontUnderlineType.DOUBLE); | |
font.setColor(Color.getBlack()); | |
fc.setStyle(style); | |
} catch(Exception e) { | |
Log.e(TAG, "Set Font", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
//Instantiating a Workbook object | |
Workbook workbook = new Workbook(); | |
Worksheet sheet = workbook.getWorksheets().get(0); | |
ConditionalFormattingCollection cfs = sheet.getConditionalFormattings(); | |
// Adds an empty conditional formatting | |
int index = cfs.add(); | |
FormatConditionCollection fcs = cfs.get(index); | |
//Sets condition formulas. | |
int conditionIndex = fcs.addCondition(FormatConditionType.CELL_VALUE, OperatorType.BETWEEN,"=A2","100"); | |
FormatCondition fc = fcs.get(conditionIndex); | |
Style style = fc.getStyle(); | |
style.setPattern(BackgroundType.REVERSE_DIAGONAL_STRIPE); | |
style.setForegroundColor(Color.fromArgb(255,255,0)); | |
style.setBackgroundColor(Color.fromArgb(0,255,255)); | |
fc.setStyle(style); | |
} catch(Exception e) { | |
Log.e(TAG, "Set Pattern", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Instantiating a Workbook object | |
Workbook workbook = new Workbook(); | |
//Accessing the added worksheet in the Excel file | |
Worksheet worksheet = workbook.getWorksheets().get(0); | |
Cells cells = worksheet.getCells(); | |
//Accessing the newly added Style to the Excel object | |
Style style = workbook.createStyle(); | |
//Setting the vertical alignment of the text in the cell | |
style.setVerticalAlignment(TextAlignmentType.CENTER); | |
//Setting the horizontal alignment of the text in the cell | |
style.setHorizontalAlignment(TextAlignmentType.CENTER); | |
//Setting the font color of the text in the cell | |
Font font = style.getFont(); | |
font.setColor(Color.getGreen()); | |
//Shrinking the text to fit in the cell | |
style.setShrinkToFit(true); | |
//Setting the bottom border of the cell | |
style.setBorder(BorderType.BOTTOM_BORDER, CellBorderType.MEDIUM, Color.getRed()); | |
//Creating StyleFlag | |
StyleFlag styleFlag = new StyleFlag(); | |
styleFlag.setHorizontalAlignment(true); | |
styleFlag.setVerticalAlignment(true); | |
styleFlag.setShrinkToFit(true); | |
styleFlag.setBottomBorder(true); | |
styleFlag.setFontColor(true); | |
//Accessing a column from the Columns collection | |
Column column = cells.getColumns().get(0); | |
//Applying the style to the column | |
column.applyStyle(style, styleFlag); | |
//Saving the Excel file | |
workbook.save(filePath + File.separator + "FormatAColumn_Out.xls"); | |
} catch(Exception e) { | |
Log.e(TAG, "Format a Column", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Instantiating a Workbook object | |
Workbook workbook = new Workbook(); | |
//Accessing the added worksheet in the Excel file | |
Worksheet worksheet = workbook.getWorksheets().get(0); | |
Cells cells = worksheet.getCells(); | |
//Accessing the newly added Style to the Excel object | |
Style style = workbook.createStyle(); | |
//Setting the vertical alignment of the text in the cell | |
style.setVerticalAlignment(TextAlignmentType.CENTER); | |
//Setting the horizontal alignment of the text in the cell | |
style.setHorizontalAlignment(TextAlignmentType.CENTER); | |
//Setting the font color of the text in the cell | |
Font font = style.getFont(); | |
font.setColor(Color.getGreen()); | |
//Shrinking the text to fit in the cell | |
style.setShrinkToFit(true); | |
//Setting the bottom border of the cell | |
style.setBorder(BorderType.BOTTOM_BORDER, CellBorderType.MEDIUM, Color.getRed()); | |
//Creating StyleFlag | |
StyleFlag styleFlag = new StyleFlag(); | |
styleFlag.setHorizontalAlignment(true); | |
styleFlag.setVerticalAlignment(true); | |
styleFlag.setShrinkToFit(true); | |
styleFlag.setBottomBorder(true); | |
styleFlag.setFontColor(true); | |
//Accessing a row from the Rows collection | |
Row row = cells.getRows().get(0); | |
//Assigning the Style object to the Style property of the row | |
row.applyStyle(style, styleFlag); | |
//Saving the Excel file | |
workbook.save(filePath + File.separator + "FormatARow_Out.xls"); | |
} catch(Exception e) { | |
Log.e(TAG, "Format a Row", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Instantiating a Workbook object | |
Workbook workbook = new Workbook(); | |
//Obtaining the reference of the first (default) worksheet by passing its sheet index | |
Worksheet worksheet = workbook.getWorksheets().get(0); | |
//Adding a new Style to the styles collection of the Workbook object | |
Style style = workbook.createStyle(); | |
//Setting the Number property to 4 which corresponds to the pattern #,##0.00 | |
style.setNumber(4); | |
//Creating an object of StyleFlag | |
StyleFlag flag = new StyleFlag(); | |
//Setting NumberFormat property to true so that only this aspect takes effect from Style object | |
flag.setNumberFormat(true); | |
//Applying style to the first row of the worksheet | |
worksheet.getCells().getRows().get(0).applyStyle(style, flag); | |
//Re-initializing the Style object | |
style = workbook.createStyle(); | |
//Setting the Custom property to the pattern d-mmm-yy | |
style.setCustom("d-mmm-yy"); | |
//Applying style to the first column of the worksheet | |
worksheet.getCells().getColumns().get(0).applyStyle(style, flag); | |
//Saving spreadsheet on disc | |
workbook.save(filePath + File.separator + "DisplayFormat_Out.xlsx"); | |
} catch(Exception e) { | |
Log.e(TAG, "Setting Display Format of Numbers and Dates for Rows and Columns", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Instantiating a Workbook object | |
Workbook workbook = new Workbook(filePath + File.separator + "Book1.xls"); | |
//Accessing the first worksheet in the Excel file | |
Worksheet worksheet = workbook.getWorksheets().get(0); | |
Cells cells = worksheet.getCells(); | |
//Accessing the "A1" cell from the worksheet | |
Cell cell = cells.get("A1"); | |
//Adding some value to the "A1" cell | |
cell.setValue("Hello Aspose!"); | |
Style style = cell.getStyle(); | |
//Setting the vertical alignment of the text in the "A1" cell | |
style.setVerticalAlignment(TextAlignmentType.CENTER); | |
//Setting the horizontal alignment of the text in the "A1" cell | |
style.setHorizontalAlignment(TextAlignmentType.CENTER); | |
//Setting the font color of the text in the "A1" cell | |
Font font = style.getFont(); | |
font.setColor(Color.getGreen()); | |
//Setting the cell to shrink according to the text contained in it | |
style.setShrinkToFit(true); | |
//Setting the bottom border | |
style.setBorder(BorderType.BOTTOM_BORDER, CellBorderType.MEDIUM, Color.getRed()); | |
//Saved style | |
cell.setStyle(style); | |
//Saving the modified Excel file in default (that is Excel 2003) format | |
workbook.save(filePath + File.separator + "StyleMethod_Out.xls"); | |
} catch (Exception e) { | |
Log.e(TAG, "Using the setStyle Method", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Instantiating a Workbook object | |
Workbook workbook = new Workbook(filePath + File.separator + "Book1.xls"); | |
//Accessing the first worksheet in the Excel file | |
Worksheet worksheet = workbook.getWorksheets().get(0); | |
Cells cells = worksheet.getCells(); | |
//Accessing the "A1" cell from the worksheet | |
Cell cell = cells.get("A1"); | |
//Adding some value to the "A1" cell | |
cell.setValue("Hello Aspose!"); | |
//Adding a new Style to the styles collection of the Excel object | |
Style style = workbook.createStyle(); | |
//Setting the vertical alignment of the text in the "A1" cell | |
style.setVerticalAlignment(TextAlignmentType.CENTER); | |
//Setting the horizontal alignment of the text in the "A1" cell | |
style.setHorizontalAlignment(TextAlignmentType.CENTER); | |
//Setting the font color of the text in the "A1" cell | |
Font font = style.getFont(); | |
font.setColor (Color.getGreen()); | |
//Setting the cell to shrink according to the text contained in it | |
style.setShrinkToFit(true); | |
//Setting the bottom border | |
style.setBorder(BorderType.BOTTOM_BORDER, CellBorderType.MEDIUM, Color.getRed()); | |
//Saved style | |
cell.setStyle(style); | |
//Saving the modified Excel file in default format | |
workbook.save(filePath + File.separator + "StyleObject_Out.xls"); | |
} catch (Exception e) { | |
Log.e(TAG, "Using the Style Object", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Instantiating a Workbook object | |
Workbook workbook = new Workbook(); | |
//Accessing the added worksheet in the Excel file | |
int sheetIndex = workbook.getWorksheets().add(); | |
Worksheet worksheet = workbook.getWorksheets().get(sheetIndex); | |
Cells cells = worksheet.getCells(); | |
//Adding the current system date to "A1" cell | |
Cell cell = cells.get("A1"); | |
cell.setValue(Calendar.getInstance()); | |
//Setting the display format of the date to number 15 to show date as "d-mmm-yy" | |
Style style = cell.getStyle(); | |
style.setNumber(15); | |
cell.setStyle(style); | |
//Adding a numeric value to "A2" cell | |
cell = cells.get("A2"); | |
cell.setValue(20); | |
//Setting the display format of the value to number 9 to show value as percentage | |
style = cell.getStyle(); | |
style.setNumber(9); | |
cell.setStyle(style); | |
//Adding a numeric value to "A3" cell | |
cell = cells.get("A3"); | |
cell.setValue(1546); | |
//Setting the display format of the value to number 6 to show value as currency | |
style = cell.getStyle(); | |
style.setNumber(6); | |
cell.setStyle(style); | |
//Saving the modified Excel file in default format | |
workbook.save(filePath + File.separator + "UsingBuiltInNumberFormats_Out.xls"); | |
} catch(Exception e) { | |
Log.e(TAG, "Using BuiltIn Number Formats", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Instantiating a Workbook object | |
Workbook workbook = new Workbook(); | |
//Accessing the added worksheet in the Excel file | |
int sheetIndex = workbook.getWorksheets().add(); | |
Worksheet worksheet = workbook.getWorksheets().get(sheetIndex); | |
Cells cells = worksheet.getCells(); | |
//Adding the current system date to "A1" cell | |
Cell cell = cells.get("A1"); | |
cell.setValue(Calendar.getInstance()); | |
//Setting the display format of the date to number 15 to show date as "d-mmm-yy" | |
Style style = cell.getStyle(); | |
style.setCustom("d-mmm-yy"); | |
cell.setStyle(style); | |
//Adding a numeric value to "A2" cell | |
cell = cells.get("A2"); | |
cell.setValue(20); | |
//Setting the display format of the value to number 9 to show value as percentage | |
style = cell.getStyle(); | |
style.setCustom("0.0%"); | |
cell.setStyle(style); | |
//Adding a numeric value to "A3" cell | |
cell = cells.get("A3"); | |
cell.setValue(1546); | |
//Setting the display format of the value to number 6 to show value as currency | |
style = cell.getStyle(); | |
style.setCustom("$#,##0;[Red]$-#,##0"); | |
cell.setStyle(style); | |
//Saving the modified Excel file in default format | |
workbook.save(filePath + File.separator + "UsingCustomNumberFormats_Out.xls"); | |
} catch(Exception e) { | |
Log.e(TAG, "Using Custom Number Formats", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Instantiating a Workbook object | |
Workbook workbook = new Workbook(); | |
//Accessing the added worksheet in the Excel file | |
int sheetIndex = workbook.getWorksheets().add(); | |
Worksheet worksheet = workbook.getWorksheets().get(sheetIndex); | |
Cells cells = worksheet.getCells(); | |
//Accessing the "A1" cell from the worksheet | |
Cell cell = cells.get("A1"); | |
//Adding some value to the "A1" cell | |
cell.setValue("Visit Aspose!"); | |
Style style = cell.getStyle(); | |
//Setting the line of the top border | |
style.setBorder(BorderType.TOP_BORDER, CellBorderType.THICK, Color.getBlack()); | |
//Setting the line of the bottom border | |
style.setBorder(BorderType.BOTTOM_BORDER, CellBorderType.THICK, Color.getBlack()); | |
//Setting the line of the left border | |
style.setBorder(BorderType.LEFT_BORDER, CellBorderType.THICK, Color.getBlack()); | |
//Setting the line of the right border | |
style.setBorder(BorderType.RIGHT_BORDER, CellBorderType.THICK, Color.getBlack()); | |
//Saving the modified style to the "A1" cell. | |
cell.setStyle(style); | |
//Saving the Excel file | |
workbook.save(filePath + File.separator + "AddBordersToACell_Out.xls"); | |
} catch (Exception e) { | |
Log.e(TAG, "Add Borders to a Cell", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Instantiating a Workbook object | |
Workbook workbook = new Workbook(); | |
//Adding a new worksheet to the Workbook object | |
//Obtaining the reference of the newly added worksheet | |
int sheetIndex = workbook.getWorksheets().add(); | |
Worksheet worksheet = workbook.getWorksheets().get(sheetIndex); | |
//Accessing the "A1" cell from the worksheet | |
Cell cell = worksheet.getCells().get("A1"); | |
//Adding some value to the "A1" cell | |
cell.setValue("Hello World From Aspose"); | |
//Creating a range of cells starting from "A1" cell to 3rd column in a row | |
Range range = worksheet.getCells().createRange(0, 0, 0, 2); | |
range.setName("MyRange"); | |
//Adding a thick outline border with the blue line | |
range.setOutlineBorders(CellBorderType.THICK, Color.getBlue()); | |
//Saving the Excel file | |
workbook.save(filePath + File.separator + "AddBordersToARangeOfCells_Out.xls"); | |
} catch (Exception e) { | |
Log.e(TAG, "Add Borders to a Range of Cells", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Instantiating a Workbook object | |
Workbook workbook = new Workbook(); | |
//Adding custom color to the palette at 55th index | |
Color color = Color.fromArgb(212,213,0); | |
workbook.changePalette(color,55); | |
//Obtaining the reference of the newly added worksheet by passing its sheet index | |
int sheetIndex = workbook.getWorksheets().add(); | |
Worksheet worksheet = workbook.getWorksheets().get(sheetIndex); | |
//Accessing the "A1" cell from the worksheet | |
Cell cell = worksheet.getCells().get("A1"); | |
//Adding some value to the "A1" cell | |
cell.setValue("Hello Aspose!"); | |
//Setting the custom color to the font | |
Style style = cell.getStyle(); | |
Font font = style.getFont(); | |
font.setColor(color); | |
cell.setStyle(style); | |
//Saving the Excel file | |
workbook.save(filePath + File.separator + "AddCustomColorsToPalette_Out.xls"); | |
} catch(Exception e) { | |
Log.e(TAG, "Add Custom Colors to Palette", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Instantiating a Workbook object | |
Workbook workbook = new Workbook(); | |
//Accessing the added worksheet in the Excel file | |
int sheetIndex = workbook.getWorksheets().add(); | |
Worksheet worksheet = workbook.getWorksheets().get(sheetIndex); | |
Cells cells = worksheet.getCells(); | |
//Accessing the "A1" cell from the worksheet | |
Cell cell=cells.get("A1"); | |
Style style = cell.getStyle(); | |
//Setting the foreground color to yellow | |
style.setBackgroundColor(Color.getYellow()); | |
//Setting the background pattern to vertical stripe | |
style.setPattern(BackgroundType.VERTICAL_STRIPE); | |
//Saving the modified style to the "A1" cell. | |
cell.setStyle(style); | |
//Accessing the "A2" cell from the worksheet | |
cell=cells.get("A2"); | |
style = cell.getStyle(); | |
//Setting the foreground color to blue | |
style.setBackgroundColor(Color.getBlue()); | |
//Setting the background color to yellow | |
style.setForegroundColor(Color.getYellow()); | |
//Setting the background pattern to vertical stripe | |
style.setPattern(BackgroundType.VERTICAL_STRIPE); | |
//Saving the modified style to the "A2" cell. | |
cell.setStyle(style); | |
//Saving the Excel file | |
workbook.save(filePath + File.separator + "ColorAndBackgroundPattern_Out.xls"); | |
} catch(Exception e) { | |
Log.e(TAG, "Set Colors and Background Patterns", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Instantiating a Workbook object | |
Workbook workbook = new Workbook(); | |
//Accessing the added worksheet in the Excel file | |
int sheetIndex = workbook.getWorksheets().add(); | |
Worksheet worksheet = workbook.getWorksheets().get(sheetIndex); | |
Cells cells = worksheet.getCells(); | |
//Adding the current system date to "A1" cell | |
Cell cell = cells.get("A1"); | |
Style style = cell.getStyle(); | |
//Adding some value to the "A1" cell | |
cell.setValue("Visit Aspose!"); | |
//Setting the horizontal alignment of the text in the "A1" cell | |
style.setHorizontalAlignment(TextAlignmentType.CENTER); | |
//Saved style | |
cell.setStyle(style); | |
//Saving the modified Excel file in default format | |
workbook.save(filePath + File.separator + "HorizontalTextAlignment_Out.xls"); | |
} catch(Exception e) { | |
Log.e(TAG, "Horizontal Text Alignment", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Instantiating a Workbook object | |
Workbook workbook = new Workbook(); | |
//Accessing the added worksheet in the Excel file | |
int sheetIndex = workbook.getWorksheets().add(); | |
Worksheet worksheet = workbook.getWorksheets().get(sheetIndex); | |
Cells cells = worksheet.getCells(); | |
//Adding the current system date to "A1" cell | |
Cell cell = cells.get("A1"); | |
//Adding some value to the "A1" cell | |
cell.setValue("Visit Aspose!"); | |
Style style = cell.getStyle(); | |
style.setIndentLevel(2); | |
cell.setStyle(style); | |
//Saving the modified Excel file in default format | |
workbook.save(filePath + File.separator + "Indentation_Out.xls"); | |
} catch(Exception e) { | |
Log.e(TAG, "Indentation", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Instantiating a Workbook object | |
Workbook workbook = new Workbook(); | |
//Accessing the added worksheet in the Excel file | |
int sheetIndex = workbook.getWorksheets().add(); | |
Worksheet worksheet = workbook.getWorksheets().get(sheetIndex); | |
Cells cells = worksheet.getCells(); | |
//Merging the first three columns in the first row to create a single cell | |
cells.merge(0, 0, 1, 3); | |
//Saving the modified Excel file in default format | |
workbook.save(filePath + File.separator + "MergeCells_Out.xls"); | |
} catch(Exception e) { | |
Log.e(TAG, "Merge Cells", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Instantiating a Workbook object | |
Workbook workbook = new Workbook(); | |
//Accessing the added worksheet in the Excel file | |
int sheetIndex = workbook.getWorksheets().add(); | |
Worksheet worksheet = workbook.getWorksheets().get(sheetIndex); | |
Cells cells = worksheet.getCells(); | |
//Adding the current system date to "A1" cell | |
Cell cell = cells.get("A1"); | |
//Adding some value to the "A1" cell | |
cell.setValue("Visit Aspose!"); | |
//Setting the rotation of the text (inside the cell) to 25 | |
Style style = cell.getStyle(); | |
style.setRotationAngle(25); | |
cell.setStyle(style); | |
//Saving the modified Excel file in default format | |
workbook.save(filePath + File.separator + "Orientation_Out.xls"); | |
} catch(Exception e) { | |
Log.e(TAG, "Orientation", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Instantiating a Workbook object | |
Workbook workbook = new Workbook(); | |
//Accessing the added worksheet in the Excel file | |
int sheetIndex = workbook.getWorksheets().add(); | |
Worksheet worksheet = workbook.getWorksheets().get(sheetIndex); | |
Cells cells = worksheet.getCells(); | |
//Adding the current system date to "A1" cell | |
Cell cell = cells.get("A1"); | |
//Adding some value to the "A1" cell | |
cell.setValue("Visit Aspose!"); | |
//Shrinking the text to fit according to the dimensions of the cell | |
Style style = cell.getStyle(); | |
style.setShrinkToFit(true); | |
cell.setStyle(style); | |
//Saving the modified Excel file in default format | |
workbook.save(filePath + File.separator + "ShrinkToFit_Out.xls"); | |
} catch(Exception e) { | |
Log.e(TAG, "Shrink to Fit", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Instantiating a Workbook object | |
Workbook workbook = new Workbook(); | |
//Accessing the added worksheet in the Excel file | |
int sheetIndex = workbook.getWorksheets().add(); | |
Worksheet worksheet = workbook.getWorksheets().get(sheetIndex); | |
Cells cells = worksheet.getCells(); | |
//Adding the current system date to "A1" cell | |
Cell cell = cells.get("A1"); | |
//Adding some value to the "A1" cell | |
cell.setValue("Visit Aspose!"); | |
//Setting the text direction from right to left | |
Style style = cell.getStyle(); | |
style.setTextDirection(TextDirectionType.RIGHT_TO_LEFT); | |
cell.setStyle(style); | |
//Saving the modified Excel file in default format | |
workbook.save(filePath + File.separator + "TextDirection_Out.xls"); | |
} catch(Exception e) { | |
Log.e(TAG, "Text Direction", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Instantiating a Workbook object | |
Workbook workbook = new Workbook(); | |
//Accessing the added worksheet in the Excel file | |
int sheetIndex = workbook.getWorksheets().add(); | |
Worksheet worksheet = workbook.getWorksheets().get(sheetIndex); | |
Cells cells = worksheet.getCells(); | |
//Adding the current system date to "A1" cell | |
Cell cell = cells.get("A1"); | |
//Adding some value to the "A1" cell | |
cell.setValue("Visit Aspose!"); | |
// Setting the vertical alignment of the text in a cell | |
Style style = cell.getStyle(); | |
style.setVerticalAlignment(TextAlignmentType.CENTER); | |
cell.setStyle(style); | |
//Saving the modified Excel file in default format | |
workbook.save(filePath + File.separator + "VerticalTextAlignment_Out.xls"); | |
} catch(Exception e) { | |
Log.e(TAG, "Vertical Text Alignment", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Instantiating a Workbook object | |
Workbook workbook = new Workbook(); | |
//Accessing the added worksheet in the Excel file | |
int sheetIndex = workbook.getWorksheets().add(); | |
Worksheet worksheet = workbook.getWorksheets().get(sheetIndex); | |
Cells cells = worksheet.getCells(); | |
//Adding the current system date to "A1" cell | |
Cell cell = cells.get("A1"); | |
//Adding some value to the "A1" cell | |
cell.setValue("Visit Aspose!"); | |
//Enabling the text to be wrapped within the cell | |
Style style = cell.getStyle(); | |
style.setTextWrapped(true); | |
cell.setStyle(style); | |
//Saving the modified Excel file in default format | |
workbook.save(filePath + File.separator + "WrapText_Out.xls"); | |
} catch(Exception e) { | |
Log.e(TAG, "Wrap Text", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Instantiating a Workbook object | |
Workbook workbook = new Workbook(); | |
//Accessing the added worksheet in the Excel file | |
int sheetIndex = workbook.getWorksheets().add(); | |
Worksheet worksheet = workbook.getWorksheets().get(sheetIndex); | |
Cells cells = worksheet.getCells(); | |
//Adding some value to the "A1" cell | |
Cell cell = cells.get("A1"); | |
cell.setValue("Hello Aspose!"); | |
//Setting the font color to blue | |
Style style = cell.getStyle(); | |
Font font = style.getFont(); | |
font.setColor(Color.getBlue()); | |
cell.setStyle(style); | |
//Saving the modified Excel file in default format | |
workbook.save(filePath + File.separator + "SetFontColor_Out.xls"); | |
} catch(Exception e) { | |
Log.e(TAG, "Set Font Color", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Instantiating a Workbook object | |
Workbook workbook = new Workbook(); | |
//Accessing the added worksheet in the Excel file | |
int sheetIndex = workbook.getWorksheets().add(); | |
Worksheet worksheet = workbook.getWorksheets().get(sheetIndex); | |
Cells cells = worksheet.getCells(); | |
//Adding some value to the "A1" cell | |
Cell cell = cells.get("A1"); | |
cell.setValue("Hello Aspose!"); | |
//Setting the font name to "Times New Roman" | |
Style style = cell.getStyle(); | |
Font font = style.getFont(); | |
font.setName("Times New Roman"); | |
cell.setStyle(style); | |
//Saving the modified Excel file in default format | |
workbook.save(filePath + File.separator + "SetFontName_Out.xls"); | |
} catch(Exception e) { | |
Log.e(TAG, "Set Font Name", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Instantiating a Workbook object | |
Workbook workbook = new Workbook(); | |
//Accessing the added worksheet in the Excel file | |
int sheetIndex = workbook.getWorksheets().add(); | |
Worksheet worksheet = workbook.getWorksheets().get(sheetIndex); | |
Cells cells = worksheet.getCells(); | |
//Adding some value to the "A1" cell | |
Cell cell = cells.get("A1"); | |
cell.setValue("Hello Aspose!"); | |
//Set the font Size | |
Style style = cell.getStyle(); | |
Font font = style.getFont(); | |
font.setSize(14); | |
cell.setStyle(style); | |
//Saving the modified Excel file in default format | |
workbook.save(filePath + File.separator + "SetFontSize_Out.xls"); | |
} catch(Exception e) { | |
Log.e(TAG, "Set Font Size", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Instantiating a Workbook object | |
Workbook workbook = new Workbook(); | |
//Accessing the added worksheet in the Excel file | |
int sheetIndex = workbook.getWorksheets().add(); | |
Worksheet worksheet = workbook.getWorksheets().get(sheetIndex); | |
Cells cells = worksheet.getCells(); | |
//Adding some value to the "A1" cell | |
Cell cell = cells.get("A1"); | |
cell.setValue("Hello Aspose!"); | |
//Setting the font weight to bold | |
Style style = cell.getStyle(); | |
Font font = style.getFont(); | |
font.setBold(true); | |
cell.setStyle(style); | |
//Saving the modified Excel file in default format | |
workbook.save(filePath + File.separator + "SetFontStyleToBold_Out.xls"); | |
} catch(Exception e) { | |
Log.e(TAG, "Set Font Style to Bold", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Instantiating a Workbook object | |
Workbook workbook = new Workbook(); | |
//Accessing the added worksheet in the Excel file | |
int sheetIndex = workbook.getWorksheets().add(); | |
Worksheet worksheet = workbook.getWorksheets().get(sheetIndex); | |
Cells cells = worksheet.getCells(); | |
//Adding some value to the "A1" cell | |
Cell cell = cells.get("A1"); | |
cell.setValue("Hello Aspose!"); | |
//Setting the font to be underlined | |
Style style = cell.getStyle(); | |
Font font = style.getFont(); | |
font.setUnderline(FontUnderlineType.SINGLE); | |
cell.setStyle(style); | |
//Saving the modified Excel file in default format | |
workbook.save(filePath + File.separator + "SetFontUnderline_Out.xls"); | |
} catch(Exception e) { | |
Log.e(TAG, "Set Font Underline Type", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Instantiating a Workbook object | |
Workbook workbook = new Workbook(); | |
//Accessing the added worksheet in the Excel file | |
int sheetIndex = workbook.getWorksheets().add(); | |
Worksheet worksheet = workbook.getWorksheets().get(sheetIndex); | |
Cells cells = worksheet.getCells(); | |
//Adding some value to the "A1" cell | |
Cell cell = cells.get("A1"); | |
cell.setValue("Hello Aspose!"); | |
//Setting the strike out effect on the font | |
Style style = cell.getStyle(); | |
Font font = style.getFont(); | |
font.setStrikeout(true); | |
cell.setStyle(style); | |
//Saving the modified Excel file in default format | |
workbook.save(filePath + File.separator + "SetStrikeOutEffectOnFont_Out.xls"); | |
} catch(Exception e) { | |
Log.e(TAG, "Set Strike Out Effect on Font", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Instantiating a Workbook object | |
Workbook workbook = new Workbook(); | |
//Accessing the added worksheet in the Excel file | |
int sheetIndex = workbook.getWorksheets().add(); | |
Worksheet worksheet = workbook.getWorksheets().get(sheetIndex); | |
Cells cells = worksheet.getCells(); | |
//Adding some value to the "A1" cell | |
Cell cell = cells.get("A1"); | |
cell.setValue("Hello Aspose!"); | |
//Setting subscript effect | |
Style style = cell.getStyle(); | |
Font font = style.getFont(); | |
font.setSubscript(true); | |
cell.setStyle(style); | |
//Saving the modified Excel file in default format | |
workbook.save(filePath + File.separator + "SetSubScriptEffectOnFont_Out.xls"); | |
} catch(Exception e) { | |
Log.e(TAG, "Set SubScript Effect on Font", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Instantiating a Workbook object | |
Workbook workbook = new Workbook(); | |
//Accessing the added worksheet in the Excel file | |
int sheetIndex = workbook.getWorksheets().add(); | |
Worksheet worksheet = workbook.getWorksheets().get(sheetIndex); | |
Cells cells = worksheet.getCells(); | |
//Adding some value to the "A1" cell | |
Cell cell = cells.get("A1"); | |
cell.setValue("Hello Aspose!"); | |
//Setting superscript effect | |
Style style = cell.getStyle(); | |
Font font = style.getFont(); | |
font.setSuperscript(true); | |
cell.setStyle(style); | |
//Saving the modified Excel file in default format | |
workbook.save(filePath + File.separator + "SetSuperScriptEffectOnFont_Out.xls"); | |
} catch(Exception e) { | |
Log.e(TAG, "Set SuperScript Effect on Font", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Instantiating a Workbook object | |
Workbook workbook = new Workbook(); | |
//Accessing the added worksheet in the Excel file | |
int sheetIndex = workbook.getWorksheets().add(); | |
Worksheet worksheet = workbook.getWorksheets().get(sheetIndex); | |
Cells cells = worksheet.getCells(); | |
//Adding some value to the "A1" cell | |
Cell cell = cells.get("A1"); | |
cell.setValue("Visit Aspose!"); | |
Font font = cell.characters(6, 7).getFont(); | |
//Setting the font of selected characters to bold | |
font.setBold(true); | |
//Setting the font color of selected characters to blue | |
font.setColor(Color.getBlue()); | |
//Saving the Excel file | |
workbook.save(filePath + File.separator + "FormatSelectedCharacters_Out.xls"); | |
} catch(Exception e) { | |
Log.e(TAG, "Format Selected Characters", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
LoadOptions loadOptions = new LoadOptions(FileFormatType.CSV); | |
Workbook workbook = new Workbook(filePath + File.separator + "Book1.csv", loadOptions); | |
} catch (Exception e) { | |
Log.e(TAG, "Open CSV Files", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Creating an EXCEL_97_TO_2003 LoadOptions object | |
LoadOptions loadOptions = new LoadOptions(FileFormatType.EXCEL_97_TO_2003); | |
//Setting the password for the encrypted Excel file | |
loadOptions.setPassword("password1"); | |
//Creating an Workbook object with excel 97 file path and the loadOptions object | |
Workbook workbook = new Workbook(filePath + File.separator + "Book1.xls", loadOptions); | |
} catch (Exception e) { | |
Log.e(TAG, "Open Encrypted Excel File", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
LoadOptions loadOptions = new LoadOptions(FileFormatType.XLSX); | |
Workbook workbook = new Workbook(filePath + File.separator + "Book1.xlsx", loadOptions); | |
} catch (Exception e) { | |
Log.e(TAG, "Open Microsoft Excel 2007 XLSX Files", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Creating an EXCEL_97_TO_2003 LoadOptions object | |
LoadOptions loadOptions = new LoadOptions(FileFormatType.EXCEL_97_TO_2003); | |
//Creating an Workbook object with excel 97 file path and the loadOptions object | |
Workbook workbook = new Workbook(filePath + File.separator + "Book1.xls", loadOptions); | |
} catch (Exception e) { | |
Log.e(TAG, "Open Microsoft Excel 97 Files", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
LoadOptions loadOptions = new LoadOptions(FileFormatType.TAB_DELIMITED); | |
Workbook workbook = new Workbook(filePath + File.separator + "Book1.txt", loadOptions); | |
} catch (Exception e) { | |
Log.e(TAG, "Open Tab Delimited File", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Creating an Workbook object with an Excel file path | |
Workbook workbook = new Workbook(filePath + File.separator + "Book1.xlsx"); | |
} catch (Exception e) { | |
Log.e(TAG, "Open through Path", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
AssetManager assetManager = context.getAssets(); | |
InputStream inputStream = assetManager.open("Book1.xlsx"); | |
//Creating an Workbook object with the stream object | |
Workbook workbook = new Workbook(inputStream); | |
} catch (Exception e) { | |
Log.e(TAG, "Open through Stream", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Load source workbook | |
Workbook workbook = new Workbook(filePath + File.separator + "source.xlsx"); | |
//0-byte array | |
byte[] workbookData = new byte[0]; | |
//Text save options. You can use any type of separator | |
TxtSaveOptions opts = new TxtSaveOptions(); | |
opts.setSeparator('\t'); | |
//Copy each worksheet data in text format inside workbook data array | |
for (int idx = 0; idx < workbook.getWorksheets().getCount(); idx++) { | |
//Save the active worksheet into text format | |
ByteArrayOutputStream bout = new ByteArrayOutputStream(); | |
workbook.getWorksheets().setActiveSheetIndex(idx); | |
workbook.save(bout, opts); | |
//Save the worksheet data into sheet data array | |
byte[] sheetData = bout.toByteArray(); | |
//Combine this worksheet data into workbook data array | |
byte[] combinedArray = new byte[workbookData.length + sheetData.length]; | |
System.arraycopy(workbookData, 0, combinedArray, 0, workbookData.length); | |
System.arraycopy(sheetData, 0, combinedArray, workbookData.length, sheetData.length); | |
workbookData = combinedArray; | |
} | |
//Save entire workbook data into file | |
FileOutputStream fout = new FileOutputStream(filePath + File.separator + "EntireWorkbookIntoText_Out.txt"); | |
fout.write(workbookData); | |
fout.close(); | |
} catch (Exception e) { | |
Log.e(TAG, "Save entire Workbook into Text or CSV Format", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
Workbook workbook = new Workbook(filePath + File.separator + "Book1.xlsx"); | |
//Save in default (Excel2003) format | |
workbook.save(filePath + File.separator + "book_out.xls"); | |
//Save in Excel2003 format | |
workbook.save(filePath + File.separator + "book_out.xls", FileFormatType.EXCEL_97_TO_2003); | |
//Save in Excel2007 xlsx format | |
workbook.save(filePath + File.separator + "book_out.xlsx", FileFormatType.XLSX); | |
//Save in SpreadsheetML format | |
workbook.save(filePath + File.separator + "book_out.xml", FileFormatType.EXCEL_2003_XML); | |
} catch (Exception e) { | |
Log.e(TAG, "Save to a location", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Create a Stream object | |
FileOutputStream stream = new FileOutputStream(filePath + File.separator + "book_out.xls"); | |
AssetManager assetManager = context.getAssets(); | |
InputStream inputStream = assetManager.open("Book1.xlsx"); | |
//Create a Workbook object with the stream object | |
Workbook workbook = new Workbook(inputStream); | |
//Save in Excel2003 format | |
workbook.save(stream, FileFormatType.EXCEL_97_TO_2003); | |
//Save in MS Excel2007 xlsx format | |
workbook.save(stream, FileFormatType.XLSX); | |
//Save in SpreadsheetML format | |
workbook.save(stream, FileFormatType.EXCEL_2003_XML); | |
} catch (Exception e) { | |
Log.e(TAG, "Save to a Stream", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
Workbook workbook = new Workbook(); | |
//Obtaining the reference of the first worksheet | |
WorksheetCollection worksheets = workbook.getWorksheets(); | |
Worksheet sheet = worksheets.get(0); | |
//Adding some sample value to cells | |
Cells cells = sheet.getCells(); | |
Cell cell = cells.get("A1"); | |
cell.setValue(50); | |
cell = cells.get("A2"); | |
cell. setValue (100); | |
cell = cells.get("A3"); | |
cell.setValue(150); | |
cell = cells.get("B1"); | |
cell.setValue(4); | |
cell = cells.get("B2"); | |
cell.setValue(20); | |
cell = cells.get("B3"); | |
cell.setValue(50); | |
ChartCollection charts = sheet.getCharts(); | |
//Adding a chart to the worksheet | |
int chartIndex = charts.add(ChartType.PYRAMID, 5, 0, 15, 5); | |
Chart chart = charts.get(chartIndex); | |
//Adding NSeries (chart data source) to the chart ranging from "A1" cell to "B3" | |
SeriesCollection series = chart.getNSeries(); | |
series.add("A1:B3", true); | |
//Get the Chart image | |
ImageOrPrintOptions imgOpts = new ImageOrPrintOptions(); | |
imgOpts.setImageFormat(ImageFormat.getEmf()); | |
//Save the chart image. | |
chart.toImage(new FileOutputStream(filePath + File.separator + "ConvertChartToImage_Out.emf"), imgOpts); | |
} catch (Exception e) { | |
Log.e(TAG, "Convert Chart to Image", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Create a workbook object from the template file | |
Workbook workbook = new Workbook(filePath + File.separator + "sample.xlsx"); | |
//Access first worksheet | |
Worksheet worksheet = workbook.getWorksheets().get(0); | |
//Access first chart inside the worksheet | |
Chart chart = worksheet.getCharts().get(0); | |
//Save the chart into pdf format | |
chart.toPdf(filePath + File.separator + "Chart_Out.pdf"); | |
} catch (Exception e) { | |
Log.e(TAG, "Convert Chart to PDF", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Create a workbook object from the template file | |
Workbook workbook = new Workbook(filePath + File.separator + "sample.xlsx"); | |
//Access first worksheet | |
Worksheet worksheet = workbook.getWorksheets().get(0); | |
//Access first chart inside the worksheet | |
Chart chart = worksheet.getCharts().get(0); | |
//Save the chart to PDF as Stream | |
ByteArrayOutputStream outStream = new ByteArrayOutputStream(); | |
chart.toPdf(outStream); | |
} catch (Exception e) { | |
Log.e(TAG, "Save Chart PDF In ByteArrayOutputStream", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Create a workbook object from the template file | |
Workbook workbook = new Workbook(filePath + File.separator + "Book1.xls"); | |
//Specify the HTML Saving Options | |
HtmlSaveOptions saveOptions = new HtmlSaveOptions(SaveFormat.HTML); | |
//Save the HTML file | |
workbook.save(filePath + File.separator + "ConvertExcelToHTML_Out.html", saveOptions); | |
} catch (Exception e) { | |
Log.e(TAG, "Convert Excel to HTML", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Create a workbook object from the template file | |
Workbook workbook = new Workbook(filePath + File.separator + "Book1.xls"); | |
//Create an instance of HtmlSaveOptions | |
HtmlSaveOptions saveOptions = new HtmlSaveOptions(SaveFormat.HTML); | |
//Set the ImageFormat to PNG | |
saveOptions.getImageOptions().setImageFormat(ImageFormat.getPng()); | |
//Set the background of image as transparent | |
saveOptions.getImageOptions().setTransparent(true); | |
//Save spreadsheet to HTML while passing object of HtmlSaveOptions | |
workbook.save(filePath + File.separator + "SetImagePreferencesForHTML_Out.html", saveOptions); | |
} catch (Exception e) { | |
Log.e(TAG, "Set Image Preferences for HTML", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Create a workbook object from the template file | |
Workbook workbook = new Workbook(filePath + File.separator + "Book1.xls"); | |
///Get the first worksheet | |
Worksheet sheet = workbook.getWorksheets().get(0); | |
//Apply different Image and Print options | |
ImageOrPrintOptions options = new ImageOrPrintOptions(); | |
//Set the format to XPS | |
options.setSaveFormat(SaveFormat.XPS); | |
//Render the sheet with respect to specified printing options | |
SheetRender render = new SheetRender(sheet, options); | |
render.toImage(0, filePath + File.separator + "ConvertWorksheetToXPS_Out.xps"); | |
} catch (Exception e) { | |
Log.e(TAG, "Convert Excel to HTML", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Create a workbook object from the template file | |
Workbook workbook = new Workbook(filePath + File.separator + "Book1.xls"); | |
//Save in XPS format | |
workbook.save(filePath + File.separator + "QuickExcelToXPSConversion_Out.xps", SaveFormat.XPS); | |
} catch (Exception e) { | |
Log.e(TAG, "Convert Excel to HTML", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
Workbook workbook = new Workbook(filePath + File.separator + "Book1.xls"); | |
//Save the document in PDF format | |
workbook.save(filePath + File.separator + "ConvertExcelToPDF_Out.pdf", FileFormatType.PDF); | |
} catch (Exception e) { | |
Log.e(TAG, "Convert Excel to PDF", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
Workbook workbook = new Workbook(filePath + File.separator + "Book1.xls"); | |
//Define PdfSaveOptions | |
PdfSaveOptions saveOptions = new PdfSaveOptions(); | |
//Set the compliance type | |
saveOptions.setCompliance(PdfCompliance.PDF_A_1_B); | |
//Save the PDF file | |
workbook.save(filePath + File.separator + "PDFAConversion_Out.pdf", saveOptions); | |
} catch (Exception e) { | |
Log.e(TAG, "PDF/A Conversion", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
Workbook workbook = new Workbook(filePath + File.separator + "Book1.xls"); | |
//Create an instance of PdfSaveOptions and pass SaveFormat to the constructor | |
PdfSaveOptions options = new PdfSaveOptions(SaveFormat.PDF); | |
//Set the CreatedTime for the PdfSaveOptions as per requirement | |
options.setCreatedTime(DateTime.getNow()); | |
//Save the workbook to PDF format while passing the object of PdfSaveOptions | |
workbook.save(filePath + File.separator + "CreationTimeForPDF_Out.pdf", SaveFormat.PDF); | |
} catch (Exception e) { | |
Log.e(TAG, "Set Creation Time For Output PDF", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
Workbook workbook = new Workbook(filePath + File.separator + "Source.html"); | |
workbook.save(filePath + File.separator + "ConvertFromMHTML_Out.xlsx"); | |
} catch (Exception e) { | |
Log.e(TAG, "Convert From MHTML", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
Workbook workbook = new Workbook(filePath + File.separator + "Book1.xls"); | |
//Specify the HTML saving options | |
HtmlSaveOptions htmlSaveOptions = new HtmlSaveOptions(SaveFormat.M_HTML); | |
//Save the MHT file | |
workbook.save(filePath + File.separator + "ConvertToMHTML_Out.mht", htmlSaveOptions); | |
} catch (Exception e) { | |
Log.e(TAG, "Convert to MHTML", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
Workbook workbook = new Workbook(filePath + File.separator + "Book1.xls"); | |
ImageOrPrintOptions imgOptions = new ImageOrPrintOptions(); | |
//Set the image type | |
imgOptions.setImageFormat(ImageFormat.getPng()); | |
//Get the first worksheet. | |
Worksheet sheet = workbook.getWorksheets().get(0); | |
//Create a SheetRender object for the target sheet | |
SheetRender sr = new SheetRender(sheet, imgOptions); | |
for (int j = 0; j < sr.getPageCount(); j++) { | |
//Generate an image for the worksheet | |
sr.toImage(j, filePath + File.separator + "MySheetImage_" + j + "_Out.png"); | |
} | |
} catch (Exception e) { | |
Log.e(TAG, "Convert to Image", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Create a workbook object from the template file | |
Workbook workbook = new Workbook(filePath + File.separator + "Book1.xls"); | |
//Create an instance of ImageOrPrintOptions & set SaveFormat as SVG | |
ImageOrPrintOptions imgOptions = new ImageOrPrintOptions(); | |
imgOptions.setSaveFormat(SaveFormat.SVG); | |
//Set OnePagePerSheet to true in order to render all contents on one image | |
imgOptions.setOnePagePerSheet(true); | |
//Get count of all Worksheets to loop over them | |
int sheetCount = workbook.getWorksheets().getCount(); | |
for(int i=0; i<sheetCount; i++) { | |
Worksheet sheet = workbook.getWorksheets().get(i); | |
//Create and initialize an instance of SheetRender | |
SheetRender sr = new SheetRender(sheet, imgOptions); | |
//Iterate over the pages | |
for (int k = 0; k < sr.getPageCount(); k++) { | |
//Output the worksheet into Svg image format | |
sr.toImage(k, filePath + File.separator + sheet.getName() + k + "_Out.svg"); | |
} | |
} | |
} catch (Exception e) { | |
Log.e(TAG, "Convert to Image", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
Workbook workbook = new Workbook(filePath + File.separator + "Book1.xls"); | |
// Retrieve a list of all custom document properties of the Excel file | |
CustomDocumentPropertyCollection customProperties = workbook.getWorksheets().getCustomDocumentProperties(); | |
// Add a custom document property to the Excel file | |
DocumentProperty publisher = customProperties.add("Publisher", "Aspose"); | |
} catch(Exception e) { | |
Log.e(TAG, "Add Custom Properties", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
Workbook workbook = new Workbook(filePath + File.separator + "Book1.xls"); | |
//Retrieve a list of all custom document properties of the Excel file | |
CustomDocumentPropertyCollection customProperties = workbook.getWorksheets().getCustomDocumentProperties(); | |
//Accessing a custom document property by using the property index | |
DocumentProperty customProperty1 = customProperties.get(3); | |
//Accessing a custom document property by using the property name | |
DocumentProperty customProperty2 = customProperties.get("Owner"); | |
} catch(Exception e) { | |
Log.e(TAG, "Get Property Using Name or Index", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
Workbook workbook = new Workbook(filePath + File.separator + "Book1.xls"); | |
// Retrieve a list of all custom document properties of the Excel file | |
CustomDocumentPropertyCollection customProperties = workbook.getWorksheets().getCustomDocumentProperties(); | |
//Remove a custom document property | |
customProperties.remove("Publisher"); | |
} catch(Exception e) { | |
Log.e(TAG, "Remove Custom Properties", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
Workbook workbook = new Workbook(filePath + File.separator + "Book1.xls"); | |
//Retrieve a list of all custom document properties of the Excel file | |
CustomDocumentPropertyCollection customProperties = workbook.getWorksheets().getCustomDocumentProperties(); | |
//Access a custom document property | |
DocumentProperty customProperty1 = customProperties.get(0); | |
//Store the value of the document property as an object | |
Object objectValue = customProperty1.getValue(); | |
//Access a custom document property | |
DocumentProperty customProperty2 = customProperties.get(1); | |
//Checking the type of the document property and then storing the value of the | |
//document property according to that type | |
if (customProperty2.getType() == PropertyType.NUMBER) { | |
int intValue = customProperty2.toInt(); | |
} | |
} catch(Exception e) { | |
Log.e(TAG, "Retrieve Name, Value And Type of Document Property", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
Workbook workbook = new Workbook(filePath + File.separator + "Book1.xls"); | |
//Password protect the file. | |
workbook.getSettings().setPassword("1234"); | |
//Specify XOR encryption type. | |
workbook.setEncryptionOptions(EncryptionType.XOR, 40); | |
//Specify Strong Encryption type (RC4,Microsoft Strong Cryptographic Provider). | |
workbook.setEncryptionOptions(EncryptionType.STRONG_CRYPTOGRAPHIC_PROVIDER, 128); | |
//Save the Excel file. | |
workbook.save(filePath + File.separator + "EncryptedBook1_out.xls"); | |
} catch(Exception e) { | |
Log.e(TAG, "Encrypt File", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Instantiating a Workbook object | |
Workbook workbook = new Workbook(filePath + File.separator + "Book1.xls"); | |
//Accessing the first worksheet in the Excel file | |
Worksheet worksheet = workbook.getWorksheets().get(0); | |
Cells cells = worksheet.getCells(); | |
//Set the width of the second column to 17.5 | |
cells.setColumnWidth(1, 17.5); | |
//Saving the modified Excel file in default (that is Excel 2003) format | |
workbook.save(filePath + File.separator + "SetColumnWidth_Out.xls"); | |
} catch (Exception e) { | |
Log.e(TAG, "Set Column Width", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Instantiating a Workbook object | |
Workbook workbook = new Workbook(filePath + File.separator + "Book1.xls"); | |
//Accessing the first worksheet in the Excel file | |
Worksheet worksheet = workbook.getWorksheets().get(0); | |
Cells cells = worksheet.getCells(); | |
//Setting the height of the second row to 13 | |
cells.setRowHeight(1, 13); | |
//Saving the modified Excel file in default (that is Excel 2003) format | |
workbook.save(filePath + File.separator + "SetRowHeight_Out.xls"); | |
} catch (Exception e) { | |
Log.e(TAG, "Set Row Height", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Instantiating a Workbook object | |
Workbook workbook = new Workbook(filePath + File.separator + "Book1.xls"); | |
//Accessing the first worksheet in the Excel file | |
Worksheet worksheet = workbook.getWorksheets().get(0); | |
Cells cells = worksheet.getCells(); | |
//Set the height of all rows in the worksheet to 15 | |
worksheet.getCells().setStandardHeight(15f); | |
//Saving the modified Excel file in default (that is Excel 2003) format | |
workbook.save(filePath + File.separator + "SetRowHeightForAllRows_Out.xls"); | |
} catch (Exception e) { | |
Log.e(TAG, "Set Row Height For All Rows", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Instantiating a Workbook object | |
Workbook workbook = new Workbook(filePath + File.separator + "Book1.xls"); | |
//Accessing the first worksheet in the Excel file | |
Worksheet worksheet = workbook.getWorksheets().get(0); | |
Cells cells = worksheet.getCells(); | |
//Set the width of all columns in the worksheet to 20.5 | |
worksheet.getCells().setStandardWidth(20.5f); | |
//Saving the modified Excel file in default (that is Excel 2003) format | |
workbook.save(filePath + File.separator + "SetWidthOfAllColumns_Out.xls"); | |
} catch (Exception e) { | |
Log.e(TAG, "Set Width Of All Columns", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Instantiating a Workbook object | |
Workbook workbook = new Workbook(filePath + File.separator + "Book1.xls"); | |
//Accessing the first worksheet in the Excel file | |
Worksheet worksheet = workbook.getWorksheets().get(0); | |
//Auto-fitting the 4th column of the worksheet | |
worksheet.autoFitColumn(3); | |
//Saving the modified Excel file in default (that is Excel 2003) format | |
workbook.save(filePath + File.separator + "AutoFitColumn_Out.xls"); | |
} catch (Exception e) { | |
Log.e(TAG, "Auto-fit Column", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Instantiating a Workbook object | |
Workbook workbook = new Workbook(filePath + File.separator + "Book1.xls"); | |
//Accessing the first worksheet in the Excel file | |
Worksheet worksheet = workbook.getWorksheets().get(0); | |
//Auto-fitting the 4th column of the worksheet based on the contents in a range of | |
//cells (from 1st to 9th row) within the column | |
worksheet.autoFitColumn(3,0,8); | |
//Saving the modified Excel file in default (that is Excel 2003) format | |
workbook.save(filePath + File.separator + "AutoFitColumnInARangeOfCells_Out.xls"); | |
} catch (Exception e) { | |
Log.e(TAG, "Auto-fit Column in a range of cells", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Instantiating a Workbook object | |
Workbook workbook = new Workbook(filePath + File.separator + "Book1.xls"); | |
//Accessing the first worksheet in the Excel file | |
Worksheet worksheet = workbook.getWorksheets().get(0); | |
//Auto-fitting the 3rd row of the worksheet | |
worksheet.autoFitRow(2); | |
//Saving the modified Excel file in default (that is Excel 2003) format | |
workbook.save(filePath + File.separator + "AutoFitRow_Out.xls"); | |
} catch (Exception e) { | |
Log.e(TAG, "Auto-fit Row", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Instantiating a Workbook object | |
Workbook workbook = new Workbook(filePath + File.separator + "Book1.xls"); | |
//Accessing the first worksheet in the Excel file | |
Worksheet worksheet = workbook.getWorksheets().get(0); | |
//Auto-fitting the 3rd row of the worksheet based on the contents in a range of | |
//cells (from 1st to 9th column) within the row | |
worksheet.autoFitRow(2,0,8); | |
//Saving the modified Excel file in default (that is Excel 2003) format | |
workbook.save(filePath + File.separator + "AutoFitRowInARangeOfCells_Out.xls"); | |
} catch (Exception e) { | |
Log.e(TAG, "Auto-fit Row in a range of cells", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
// Create a new Workbook. | |
Workbook excelWorkbook0 = new Workbook(); | |
// Get the first worksheet in the book. | |
Worksheet ws0 = excelWorkbook0.getWorksheets().get(0); | |
// Put some data into header rows (A1:A4) | |
for (int i = 1; i < 5; i++) { | |
ws0.getCells().get("A" + i).setValue("Header Row " + i); | |
} | |
// Put some detail data (A5:A999) | |
for (int i = 5; i < 1000; i++) { | |
ws0.getCells().get("A" + i).setValue("Detail Row " + i); | |
} | |
// Create another Workbook. | |
Workbook excelWorkbook1 = new Workbook(); | |
// Get the first worksheet in the book. | |
Worksheet ws1 = excelWorkbook1.getWorksheets().get(0); | |
// Copy the first column from the first worksheet of the first workbook into | |
// the first worksheet of the second workbook. | |
ws1.getCells().copyColumn(ws0.getCells(), 0, 2); | |
// Autofit the column. | |
ws1.autoFitColumn(2); | |
// Save the Excel file. | |
excelWorkbook1.save(filePath + File.separator + "CopyColumn.xls"); | |
} catch (Exception e) { | |
Log.e(TAG, "Copy Columns", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Instantiating a Workbook object | |
Workbook workbook = new Workbook(filePath + File.separator + "Book1.xls"); | |
//Accessing the first worksheet in the Excel file | |
Worksheet worksheet = workbook.getWorksheets().get(0); | |
//Copy the second row with data, formatting, images and drawing objects | |
//to the 12th row in the worksheet. | |
worksheet.getCells().copyRow(worksheet.getCells(), 1, 11); | |
//Saving the modified Excel file in default (that is Excel 2003) format | |
workbook.save(filePath + File.separator + "CopyRows_Out.xls"); | |
} catch (Exception e) { | |
Log.e(TAG, "Copy Rows", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Instantiating a Workbook object | |
Workbook workbook = new Workbook(filePath + File.separator + "Book1.xls"); | |
//Accessing the first worksheet in the Excel file | |
Worksheet worksheet = workbook.getWorksheets().get(0); | |
Cells cells = worksheet.getCells(); | |
//Grouping first six rows (from 0 to 5) and making them hidden by passing true | |
cells.groupRows(0,5,true); | |
//Grouping first three columns (from 0 to 2) and making them hidden by passing true | |
cells.groupColumns(0,2,true); | |
//Saving the modified Excel file in default (that is Excel 2003) format | |
workbook.save(filePath + File.separator + "GroupRowsAndColumns_Out.xls"); | |
} catch (Exception e) { | |
Log.e(TAG, "Group Rows And Columns", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Instantiating a Workbook object | |
Workbook workbook = new Workbook(filePath + File.separator + "Book1.xls"); | |
//Accessing the first worksheet in the Excel file | |
Worksheet worksheet = workbook.getWorksheets().get(0); | |
//SummaryRowBelow controls whether there's a summary row below the group. | |
worksheet.getOutline().SummaryRowBelow = false; | |
//SummaryColumnRight controls whether there's a summary row to the right of the group. | |
worksheet.getOutline().SummaryColumnRight = false; | |
} catch (Exception e) { | |
Log.e(TAG, "Summary Rows Below Detail", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Instantiating a Workbook object | |
Workbook workbook = new Workbook(filePath + File.separator + "Book1.xls"); | |
//Accessing the first worksheet in the Excel file | |
Worksheet worksheet = workbook.getWorksheets().get(0); | |
Cells cells = worksheet.getCells(); | |
//Ungrouping first six rows (from 0 to 5) | |
cells.ungroupRows(0,5); | |
//Ungrouping first three columns (from 0 to 2) | |
cells.ungroupColumns(0,2); | |
//Saving the modified Excel file in default (that is Excel 2003) format | |
workbook.save(filePath + File.separator + "UngroupRowsAndColumns_Out.xls"); | |
} catch (Exception e) { | |
Log.e(TAG, "UnGroup Rows And Columns", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Instantiating a Workbook object | |
Workbook workbook = new Workbook(filePath + File.separator + "Book1.xls"); | |
//Accessing the first worksheet in the Excel file | |
Worksheet worksheet = workbook.getWorksheets().get(0); | |
Cells cells = worksheet.getCells(); | |
//Hiding the 3rd row of the worksheet | |
cells.hideRow(2); | |
//Hiding the 2nd column of the worksheet | |
cells.hideColumn(1); | |
//Saving the modified Excel file in default (that is Excel 2003) format | |
workbook.save(filePath + File.separator + "HideRowsAndColumns_Out.xls"); | |
} catch (Exception e) { | |
Log.e(TAG, "Hide Rows And Columns", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Instantiating a Workbook object | |
Workbook workbook = new Workbook(filePath + File.separator + "Book1.xls"); | |
//Accessing the first worksheet in the Excel file | |
Worksheet worksheet = workbook.getWorksheets().get(0); | |
Cells cells = worksheet.getCells(); | |
//Unhiding the 3rd row and setting its height to 13.5 | |
cells.unhideRow(2,13.5); | |
//Unhiding the 2nd column and setting its width to 8.5 | |
cells.unhideColumn(1,8.5); | |
//Saving the modified Excel file in default (that is Excel 2003) format | |
workbook.save(filePath + File.separator + "ShowRowsAndColumns_Out.xls"); | |
} catch (Exception e) { | |
Log.e(TAG, "Show Rows And Columns", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Instantiating a Workbook object | |
Workbook workbook = new Workbook(filePath + File.separator + "Book1.xls"); | |
//Accessing the first worksheet in the Excel file | |
Worksheet worksheet = workbook.getWorksheets().get(0); | |
//Deleting a column from the worksheet at 2nd position | |
worksheet.getCells().deleteColumns(1,1,true); | |
//Saving the modified Excel file in default (that is Excel 2000) format | |
workbook.save(filePath + File.separator + "InsertRows_Out.xls"); | |
} catch (Exception e) { | |
Log.e(TAG, "Delete Columns", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Instantiating a Workbook object | |
Workbook workbook = new Workbook(filePath + File.separator + "Book1.xls"); | |
//Accessing the first worksheet in the Excel file | |
Worksheet worksheet = workbook.getWorksheets().get(0); | |
//Deleting 3rd row from the worksheet | |
worksheet.getCells().deleteRows(2,1,true); | |
//Deleting 10 rows from the worksheet starting from 3rd row | |
//worksheet.getCells().deleteRows(2,10,true); | |
//Saving the modified Excel file in default (that is Excel 2000) format | |
workbook.save(filePath + File.separator + "InsertRows_Out.xls"); | |
} catch (Exception e) { | |
Log.e(TAG, "Delete Rows", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Instantiating a Workbook object | |
Workbook workbook = new Workbook(filePath + File.separator + "Book1.xls"); | |
//Accessing the first worksheet in the Excel file | |
Worksheet worksheet = workbook.getWorksheets().get(0); | |
//Inserting a column into the worksheet at 2nd position | |
worksheet.getCells().insertColumns(1,1); | |
//Saving the modified Excel file in default (that is Excel 2000) format | |
workbook.save(filePath + File.separator + "InsertRows_Out.xls"); | |
} catch (Exception e) { | |
Log.e(TAG, "Insert Columns", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Instantiating a Workbook object | |
Workbook workbook = new Workbook(filePath + File.separator + "Book1.xls"); | |
//Accessing the first worksheet in the Excel file | |
Worksheet worksheet = workbook.getWorksheets().get(0); | |
//Inserting a row into the worksheet at 3rd position | |
worksheet.getCells().insertRows(2,1); | |
//Inserting 10 rows into the worksheet starting from 3rd row | |
//worksheet.getCells().insertRows(2,10); | |
//Saving the modified Excel file in default (that is Excel 2000) format | |
workbook.save(filePath + File.separator + "InsertRows_Out.xls"); | |
} catch (Exception e) { | |
Log.e(TAG, "Insert Rows", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Instantiating a Workbook object | |
Workbook workbook = new Workbook(filePath + File.separator + "Book1.xls"); | |
WorksheetCollection worksheets = workbook.getWorksheets(); | |
Worksheet worksheet = worksheets.get(0); | |
//Applying freeze panes settings | |
worksheet.freezePanes(3,2,3,2); | |
workbook.save(filePath + File.separator + "FreezePanes_Out.xls"); | |
} catch (Exception e) { | |
Log.e(TAG, "Set Freeze Panes", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Instantiating a Workbook object | |
Workbook workbook = new Workbook(filePath + File.separator + "Book1.xls"); | |
//Adding a new worksheet to the Workbook object | |
WorksheetCollection worksheets = workbook.getWorksheets(); | |
Worksheet worksheet = worksheets.get(0); | |
//Hide the worksheet of the Excel file | |
worksheet.setVisible(false); | |
} catch (Exception e) { | |
Log.e(TAG, "Hide a Worksheet", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Instantiating a Workbook object | |
Workbook workbook = new Workbook(filePath + File.separator + "Book1.xls"); | |
//Adding a new worksheet to the Workbook object | |
WorksheetCollection worksheets = workbook.getWorksheets(); | |
Worksheet worksheet = worksheets.get(0); | |
//Display the worksheet of the Excel file | |
worksheet.setVisible(true); | |
//Saving the modified Excel file in default (that is Excel 2003) format | |
workbook.save(filePath + File.separator + "MakeAWorksheetVisible_Out.xls"); | |
} catch (Exception e) { | |
Log.e(TAG, "Make a Worksheet Visible", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Instantiating a Workbook object | |
Workbook workbook = new Workbook(filePath + File.separator + "Book1.xls"); | |
//Adding a new worksheet to the Workbook object | |
WorksheetCollection worksheets = workbook.getWorksheets(); | |
Worksheet worksheet = worksheets.get(0); | |
//Hiding the worksheet of the Excel file | |
worksheet.setVisibilityType(VisibilityType.VERY_HIDDEN); | |
} catch (Exception e) { | |
Log.e(TAG, "Set Visibility Type", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Instantiating a Workbook object | |
Workbook workbook = new Workbook(filePath + File.separator + "Book1.xls"); | |
//Adding a new worksheet to the Workbook object | |
WorksheetCollection worksheets = workbook.getWorksheets(); | |
Worksheet worksheet = worksheets.get(0); | |
//Hide gridlines of the worksheet | |
worksheet.setGridlinesVisible(false); | |
workbook.save(filePath + File.separator + "HideGridlines_Out.xls"); | |
} catch (Exception e) { | |
Log.e(TAG, "Hide Gridlines", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Instantiating a Workbook object | |
Workbook workbook = new Workbook(filePath + File.separator + "Book1.xls"); | |
//Adding a new worksheet to the Workbook object | |
WorksheetCollection worksheets = workbook.getWorksheets(); | |
Worksheet worksheet = worksheets.get(0); | |
//Display the gridlines of the worksheet | |
worksheet.setGridlinesVisible(true); | |
workbook.save(filePath + File.separator + "MakeGridlinesVisible_Out.xls"); | |
} catch (Exception e) { | |
Log.e(TAG, "Make Gridlines Visible", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Instantiating a Workbook object | |
Workbook workbook = new Workbook(filePath + File.separator + "Book1.xls"); | |
WorksheetCollection worksheets = workbook.getWorksheets(); | |
Worksheet worksheet = worksheets.get(0); | |
//Hide the headers of rows and columns | |
worksheet.setRowColumnHeadersVisible(false); | |
workbook.save(filePath + File.separator + "HideRowAndColumnHeaders_Out.xls"); | |
} catch (Exception e) { | |
Log.e(TAG, "Hide row and column headers", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Instantiating a Workbook object | |
Workbook workbook = new Workbook(filePath + File.separator + "Book1.xls"); | |
WorksheetCollection worksheets = workbook.getWorksheets(); | |
Worksheet worksheet = worksheets.get(0); | |
//Display the headers of rows and columns | |
worksheet.setRowColumnHeadersVisible(true); | |
workbook.save(filePath + File.separator + "ShowRowAndColumnHeaders_Out.xls"); | |
} catch (Exception e) { | |
Log.e(TAG, "Hide row and column headers", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Instantiating a Workbook object | |
Workbook workbook = new Workbook(filePath + File.separator + "Book1.xls"); | |
//Hide the vertical scroll bar of the Excel file | |
workbook.getSettings().setVScrollBarVisible(false); | |
//Hide the horizontal scroll bar of the Excel file | |
workbook.getSettings().setHScrollBarVisible(false); | |
workbook.save(filePath + File.separator + "HideScrollBars_Out.xls"); | |
} catch (Exception e) { | |
Log.e(TAG, "Hide Scroll Bars", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Instantiating a Workbook object | |
Workbook workbook = new Workbook(filePath + File.separator + "Book1.xls"); | |
//Display the vertical scroll bar of the Excel file | |
workbook.getSettings().setVScrollBarVisible(true); | |
//Display the horizontal scroll bar of the Excel file | |
workbook.getSettings().setHScrollBarVisible(true); | |
workbook.save(filePath + File.separator + "MakeScrollBarsVisible_Out.xls"); | |
} catch (Exception e) { | |
Log.e(TAG, "Make ScrollBarsVisible Scroll Bars", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Instantiating a Workbook object | |
Workbook workbook = new Workbook(filePath + File.separator + "Book1.xls"); | |
//Hide the tabs of the Excel file | |
workbook.getSettings().setShowTabs(false); | |
workbook.save(filePath + File.separator + "HideTabs_Out.xls"); | |
} catch (Exception e) { | |
Log.e(TAG, "Hide Tabs", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Instantiating a Workbook object | |
Workbook workbook = new Workbook(filePath + File.separator + "Book1.xls"); | |
//Display the tabs of the Excel file | |
workbook.getSettings().setShowTabs(true); | |
workbook.save(filePath + File.separator + "MakeTabsVisible_Out.xls"); | |
} catch (Exception e) { | |
Log.e(TAG, "Make Tabs Visible", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Instantiating a Workbook object | |
Workbook workbook = new Workbook(filePath + File.separator + "Book1.xls"); | |
//Adding a new worksheet to the Workbook object | |
WorksheetCollection worksheets = workbook.getWorksheets(); | |
Worksheet worksheet = worksheets.get(0); | |
//Displaying the worksheet in page break preview | |
worksheet.setPageBreakPreview(false); | |
workbook.save(filePath + File.separator + "EnableNormalView_Out.xls"); | |
} catch (Exception e) { | |
Log.e(TAG, "Enable Normal View", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Instantiating a Workbook object | |
Workbook workbook = new Workbook(filePath + File.separator + "Book1.xls"); | |
//Adding a new worksheet to the Workbook object | |
WorksheetCollection worksheets = workbook.getWorksheets(); | |
Worksheet worksheet = worksheets.get(0); | |
//Displaying the worksheet in page break preview | |
worksheet.setPageBreakPreview(true); | |
workbook.save(filePath + File.separator + "EnablePageBreakPreview_Out.xls"); | |
} catch (Exception e) { | |
Log.e(TAG, "Enable Page Break Preview", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Instantiating a Workbook object | |
Workbook workbook = new Workbook(filePath + File.separator + "Book1.xls"); | |
//Set the active cell | |
workbook.getWorksheets().get(0).setActiveCell("A20"); | |
//Remove split panes | |
workbook.getWorksheets().get(0).removeSplit(); | |
workbook.save(filePath + File.separator + "RemovePanes_Out.xls"); | |
} catch (Exception e) { | |
Log.e(TAG, "Remove Panes", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Instantiating a Workbook object | |
Workbook workbook = new Workbook(filePath + File.separator + "Book1.xls"); | |
//Set the active cell | |
workbook.getWorksheets().get(0).setActiveCell("A20"); | |
//Split the worksheet window | |
workbook.getWorksheets().get(0).split(); | |
workbook.save(filePath + File.separator + "SplitPanes_Out.xls"); | |
} catch (Exception e) { | |
Log.e(TAG, "Split Panes", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Instantiating a Workbook object | |
Workbook workbook = new Workbook(filePath + File.separator + "Book1.xls"); | |
WorksheetCollection worksheets = workbook.getWorksheets(); | |
Worksheet worksheet = worksheets.get(0); | |
//Setting the zoom factor of the worksheet to 75 | |
worksheet.setZoom(75); | |
workbook.save(filePath + File.separator + "ZoomFactor_Out.xls"); | |
} catch (Exception e) { | |
Log.e(TAG, "Controlling the Zoom Factor", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
// Creating a file stream containing the Excel file to be opened | |
FileInputStream fstream = new FileInputStream(filePath + File.separator + "Book1.xls"); | |
// Instantiating a Workbook object with the stream | |
Workbook workbook = new Workbook(fstream); | |
// Access a worksheet using its sheet name | |
Worksheet worksheet = workbook.getWorksheets().get("Sheet1"); | |
} catch (Exception e) { | |
Log.e(TAG, "Access Worksheet using Sheet Name", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Creating a file stream containing the Excel file to be opened | |
FileInputStream fstream = new FileInputStream(filePath + File.separator + "Book1.xls"); | |
//Instantiating a Workbook object with the stream | |
Workbook workbook = new Workbook(fstream); | |
//Adding a new worksheet to the Workbook object | |
WorksheetCollection worksheets = workbook.getWorksheets(); | |
int sheetIndex = worksheets.add(); | |
Worksheet worksheet = worksheets.get(sheetIndex); | |
//Setting the name of the newly added worksheet | |
worksheet.setName("New Worksheet"); | |
//Saving the Excel file | |
workbook.save(filePath + File.separator + "AddWorksheetToADesignerSpreadsheet_Out.xls"); | |
//Close the file stream to free all resources | |
fstream.close(); | |
} catch (Exception e) { | |
Log.e(TAG, "Add Worksheets to a Designer Spreadsheet", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Instantiating a Workbook object | |
Workbook workbook = new Workbook(); | |
//Adding a new worksheet to the Workbook object | |
WorksheetCollection worksheets = workbook.getWorksheets(); | |
int sheetIndex = worksheets.add(); | |
Worksheet worksheet = worksheets.get(sheetIndex); | |
//Setting the name of the newly added worksheet | |
worksheet.setName("New Worksheet"); | |
//Saving the Excel file | |
workbook.save(filePath + File.separator + "NewExcelFile_Out.xls"); | |
} catch (Exception e) { | |
Log.e(TAG, "Create a New Excel File", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
// Creating a file stream containing the Excel file to be opened | |
FileInputStream fstream = new FileInputStream(filePath + File.separator + "Book1.xls"); | |
// Instantiating a Workbook object with the stream | |
Workbook workbook = new Workbook(fstream); | |
//Remove a worksheet using its sheet index | |
workbook.getWorksheets().removeAt(0); | |
} catch (Exception e) { | |
Log.e(TAG, "Remove Worksheet Using Sheet Index", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
// Creating a file stream containing the Excel file to be opened | |
FileInputStream fstream = new FileInputStream(filePath + File.separator + "Book1.xls"); | |
// Instantiating a Workbook object with the stream | |
Workbook workbook = new Workbook(fstream); | |
//Remove a worksheet using its sheet name | |
workbook.getWorksheets().removeAt("Sheet1"); | |
} catch (Exception e) { | |
Log.e(TAG, "Access Worksheet using Sheet Name", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Create a new Workbook. | |
Workbook excelWorkbook0 = new Workbook(); | |
//Get the first worksheet in the book. | |
Worksheet ws0 = excelWorkbook0.getWorksheets().get(0); | |
//Put some data into header rows (A1:A4) | |
for (int i = 1; i < 5; i++) { | |
ws0.getCells().get("A" + i).setValue("Header Row " + i); | |
} | |
//Put some detail data (A5:A999) | |
for (int i = 5; i < 1000; i++) { | |
ws0.getCells().get("A" + i).setValue("Detail Row " + i); | |
} | |
//Define a pagesetup object based on the first worksheet. | |
PageSetup pagesetup = ws0.getPageSetup(); | |
//The first five rows are repeated in each page... | |
//It can be seen in print preview. | |
pagesetup.setPrintTitleRows("$1:$5"); | |
//Create another Workbook. | |
Workbook excelWorkbook1 = new Workbook(); | |
//Get the first worksheet in the book. | |
Worksheet ws1 = excelWorkbook1.getWorksheets().get(0); | |
//Name the worksheet. | |
ws1.setName("MySheet"); | |
//Copy data from the first worksheet of the first workbook into the | |
//first worksheet of the second workbook. | |
ws1.copy(ws0); | |
//Save the Excel file. | |
excelWorkbook1.save(filePath + File.separator + "CopyAWorksheetDataFromOneWorkbookToAnother_Out.xls", FileFormatType.EXCEL_97_TO_2003); | |
} catch (Exception e) { | |
Log.e(TAG, "Copy a worksheet data from one workbook to another workbook", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Create a Workbook | |
Workbook excelWorkbook0 = new Workbook(filePath + File.separator + "Book1.xls"); | |
//Create another Workbook | |
Workbook excelWorkbook1 = new Workbook(); | |
//Copy the first sheet of the first book into second book | |
excelWorkbook1.getWorksheets().get(0).copy(excelWorkbook0.getWorksheets().get(0)); | |
//Save the file. | |
excelWorkbook1.save(filePath + File.separator + "CopyWorksheetsBetweenWorkbooks_Out.xls", FileFormatType.EXCEL_97_TO_2003); | |
} catch (Exception e) { | |
Log.e(TAG, "Copy Worksheets Between Workbook", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
Workbook wb = new Workbook(filePath + File.separator + "Book1.xls"); | |
WorksheetCollection sheets = wb.getWorksheets(); | |
//Copy data to a new sheet from an existing sheet within the Workbook. | |
sheets.addCopy("Sheet1"); | |
//Save the Excel file. | |
wb.save(filePath + File.separator + "CopyWorksheetsWithinAWorkbook_Out.xls"); | |
} catch (Exception e) { | |
Log.e(TAG, "Copy Worksheets within a Workbook", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Create a new Workbook. | |
Workbook wb = new Workbook(filePath + File.separator + "Book1.xls"); | |
//Get the first worksheet in the book. | |
Worksheet sheet = wb.getWorksheets().get(0); | |
//Move the first sheet to the third position in the workbook. | |
sheet.moveTo(2); | |
//Save the Excel file. | |
wb.save(filePath + File.separator + "MoveWorksheetsWithinWorkbook_Out.xls"); | |
} catch(Exception e) { | |
Log.e(TAG, "Moving Worksheets within Workbook", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
// Instantiate a Workbook object | |
Workbook workbook = new Workbook(); | |
// Add a page break at cell Y30 | |
WorksheetCollection worksheets = workbook.getWorksheets(); | |
Worksheet worksheet = worksheets.get(0); | |
HorizontalPageBreakCollection hPageBreaks= worksheet.getHorizontalPageBreaks(); | |
hPageBreaks.add("Y30"); | |
VerticalPageBreakCollection vPageBreaks= worksheet.getVerticalPageBreaks(); | |
vPageBreaks.add("Y30"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
//Instantiating a Workbook object | |
Workbook workbook = new Workbook(); | |
workbook.getWorksheets().get(0).getHorizontalPageBreaks().clear(); | |
workbook.getWorksheets().get(0).getVerticalPageBreaks().clear(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath() + File.separator; | |
Workbook workbook = new Workbook(filePath + "PageBreaks.xls"); | |
Worksheet worksheet = workbook.getWorksheets().get(0); | |
HorizontalPageBreakCollection hPageBreaks = worksheet.getHorizontalPageBreaks(); | |
hPageBreaks.removeAt(0); | |
VerticalPageBreakCollection vPageBreaks = worksheet.getVerticalPageBreaks(); | |
vPageBreaks.removeAt(0); | |
} catch (Exception e) { | |
Log.e(TAG, "Remove Specific Page Break", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
//Instantiating a Workbook object | |
Workbook workbook = new Workbook(); | |
//Accessing the first worksheet in the Excel file | |
WorksheetCollection worksheets = workbook.getWorksheets(); | |
int sheetIndex = worksheets.add(); | |
Worksheet sheet = worksheets.get(sheetIndex); | |
//Setting the first page number of the worksheet pages | |
PageSetup pageSetup = sheet.getPageSetup(); | |
pageSetup.setFirstPageNumber(2); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
// Instantiating a Workbook object | |
Workbook workbook = new Workbook(); | |
// Accessing the first worksheet in the Excel file | |
WorksheetCollection worksheets = workbook.getWorksheets(); | |
int sheetIndex = worksheets.add(); | |
Worksheet sheet = worksheets.get(sheetIndex); | |
PageSetup pageSetup = sheet.getPageSetup(); | |
// Setting the number of pages to which the length of the worksheet will | |
// be spanned | |
pageSetup.setFitToPagesTall(1); | |
// Setting the number of pages to which the width of the worksheet will | |
// be spanned | |
pageSetup.setFitToPagesWide(1); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
//Instantiating a Workbook object | |
Workbook workbook = new Workbook(); | |
//Accessing the first worksheet in the Excel file | |
WorksheetCollection worksheets = workbook.getWorksheets(); | |
int sheetIndex = worksheets.add(); | |
Worksheet sheet = worksheets.get(sheetIndex); | |
//Setting the orientation to Portrait | |
PageSetup pageSetup = sheet.getPageSetup(); | |
pageSetup.setOrientation(PageOrientationType.PORTRAIT); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
//Instantiating a Workbook object | |
Workbook workbook =new Workbook(); | |
//Accessing the first worksheet in the Excel file | |
WorksheetCollection worksheets = workbook.getWorksheets(); | |
int sheetIndex = worksheets.add(); | |
Worksheet sheet = worksheets.get(sheetIndex); | |
//Setting the paper size to A4 | |
PageSetup pageSetup = sheet.getPageSetup(); | |
pageSetup.setPaperSize(PaperSizeType.PAPER_A_4); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
//Instantiating a Workbook object | |
Workbook workbook = new Workbook(); | |
//Accessing the first worksheet in the Excel file | |
WorksheetCollection worksheets = workbook.getWorksheets(); | |
int sheetIndex = worksheets.add(); | |
Worksheet sheet = worksheets.get(sheetIndex); | |
//Setting the print quality of the worksheet to 180 dpi | |
PageSetup pageSetup = sheet.getPageSetup(); | |
pageSetup.setPrintQuality(180); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
//Instantiating a Excel object | |
Workbook workbook = new Workbook(); | |
//Accessing the first worksheet in the Excel file | |
WorksheetCollection worksheets = workbook.getWorksheets(); | |
int sheetIndex = worksheets.add(); | |
Worksheet sheet = worksheets.get(sheetIndex); | |
//Setting the scaling factor to 100 | |
PageSetup pageSetup = sheet.getPageSetup(); | |
pageSetup.setZoom(100); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
//Instantiating a Workbook object | |
Workbook workbook=new Workbook(); | |
//Accessing the first worksheet in the Workbook file | |
WorksheetCollection worksheets = workbook.getWorksheets(); | |
Worksheet sheet = worksheets.get(0); | |
//Obtaining the reference of the PageSetup of the worksheet | |
PageSetup pageSetup = sheet.getPageSetup(); | |
//Allowing to print gridlines | |
pageSetup.setPrintGridlines(true); | |
//Allowing to print row/column headings | |
pageSetup.setPrintHeadings(true); | |
//Allowing to print worksheet in black & white mode | |
pageSetup.setBlackAndWhite (true); | |
//Allowing to print comments as displayed on worksheet | |
pageSetup.setPrintComments ( PrintCommentsType.PRINT_IN_PLACE); | |
//Allowing to print worksheet with draft quality | |
pageSetup.setPrintDraft(true); | |
//Allowing to print cell errors as N/A | |
pageSetup.setPrintErrors(PrintErrorsType.PRINT_ERRORS_NA); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
//Instantiating a Workbook object | |
Workbook workbook=new Workbook(); | |
//Accessing the first worksheet in the Workbook file | |
WorksheetCollection worksheets = workbook.getWorksheets(); | |
Worksheet sheet = worksheets.get(0); | |
//Obtaining the reference of the PageSetup of the worksheet | |
PageSetup pageSetup = sheet.getPageSetup(); | |
//Setting the printing order of the pages to over then down | |
pageSetup.setOrder(PrintOrderType.OVER_THEN_DOWN); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
//Instantiating a Workbook object | |
Workbook workbook=new Workbook(); | |
//Accessing the first worksheet in the Workbook file | |
WorksheetCollection worksheets = workbook.getWorksheets(); | |
Worksheet sheet = worksheets.get(0); | |
//Obtaining the reference of the PageSetup of the worksheet | |
PageSetup pageSetup = sheet.getPageSetup(); | |
//Specifying the cells range (from A1 cell to T35 cell) of the print area | |
pageSetup.setPrintArea("A1:T35"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
//Instantiating a Workbook object | |
Workbook workbook=new Workbook(); | |
//Accessing the first worksheet in the Workbook file | |
WorksheetCollection worksheets = workbook.getWorksheets(); | |
Worksheet sheet = worksheets.get(0); | |
//Obtaining the reference of the PageSetup of the worksheet | |
PageSetup pageSetup = sheet.getPageSetup(); | |
//Defining column numbers A & B as title columns | |
pageSetup.setPrintTitleColumns("$A:$B"); | |
//Defining row numbers 1 & 2 as title rows | |
pageSetup.setPrintTitleRows("$1:$2"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
//Create a workbook object | |
Workbook workbook = new Workbook(); | |
//Get the worksheets in the workbook | |
WorksheetCollection worksheets = workbook.getWorksheets(); | |
//Get the first (default) worksheet | |
Worksheet worksheet = worksheets.get(0); | |
//Get the pagesetup object | |
PageSetup pageSetup = worksheet.getPageSetup(); | |
//Specify Center on page Horizontally and Vertically | |
pageSetup.setCenterHorizontally(true); | |
pageSetup.setCenterVertically(true); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
//Create a workbook object | |
Workbook workbook = new Workbook(); | |
//Get the worksheets in the workbook | |
WorksheetCollection worksheets = workbook.getWorksheets(); | |
//Get the first (default) worksheet | |
Worksheet worksheet = worksheets.get(0); | |
//Get the pagesetup object | |
PageSetup pageSetup = worksheet.getPageSetup(); | |
//Set bottom,left,right and top page margins | |
pageSetup.setBottomMargin(2); | |
pageSetup.setLeftMargin(1); | |
pageSetup.setRightMargin(1); | |
pageSetup.setTopMargin(3); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Instantiating a Workbook object | |
Workbook workbook = new Workbook(filePath + File.separator + "Book1.xls"); | |
WorksheetCollection worksheets = workbook.getWorksheets(); | |
Worksheet worksheet = worksheets.get(0); | |
Protection protection = worksheet.getProtection(); | |
//Restricting users to delete columns of the worksheet | |
protection.setAllowDeletingColumn(false); | |
//Restricting users to delete row of the worksheet | |
protection.setAllowDeletingRow(false); | |
//Restricting users to edit contents of the worksheet | |
protection.setAllowEditingContent(false); | |
//Restricting users to edit objects of the worksheet | |
protection.setAllowEditingObject(false); | |
//Restricting users to edit scenarios of the worksheet | |
protection.setAllowEditingScenario(false); | |
//Restricting users to filter | |
protection.setAllowFiltering(false); | |
//Allowing users to format cells of the worksheet | |
protection.setAllowFormattingCell(true); | |
//Allowing users to format rows of the worksheet | |
protection.setAllowFormattingRow(true); | |
//Allowing users to insert columns in the worksheet | |
protection.setAllowInsertingColumn(true); | |
//Allowing users to insert hyperlinks in the worksheet | |
protection.setAllowInsertingHyperlink(true); | |
//Allowing users to insert rows in the worksheet | |
protection.setAllowInsertingRow(true); | |
//Allowing users to select locked cells of the worksheet | |
protection.setAllowSelectingLockedCell(true); | |
//Allowing users to select unlocked cells of the worksheet | |
protection.setAllowSelectingUnlockedCell(true); | |
//Allowing users to sort | |
protection.setAllowSorting(true); | |
//Allowing users to use pivot tables in the worksheet | |
protection.setAllowUsingPivotTable(true); | |
workbook.save(filePath + File.separator + "AdvanceProtectionSettings_Out.xls", FileFormatType.EXCEL_97_TO_2003); | |
} catch (Exception e) { | |
Log.e(TAG, "Advance Protection Settings", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Instantiating a Workbook object | |
Workbook workbook = new Workbook(filePath + File.separator + "Book1.xls"); | |
WorksheetCollection worksheets = workbook.getWorksheets(); | |
Worksheet worksheet = worksheets.get(0); | |
Cell cell = worksheet.getCells().get("A1"); | |
Style style = cell.getStyle(); | |
//Locking a cell | |
style.setLocked(true); | |
cell.setStyle(style); | |
} catch(Exception e) { | |
Log.e(TAG, "Lock Cells", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
// Create a new workbook. | |
Workbook workbook = new Workbook(); | |
//Accessing the first worksheet in the Excel file | |
WorksheetCollection worksheets = workbook.getWorksheets(); | |
Worksheet worksheet = worksheets.get(0); | |
// Define the style object. | |
Style style; | |
// Define the styleflag object. | |
StyleFlag flag; | |
// Loop through all the columns in the worksheet and unlock them. | |
for(int i = 0; i <= 255; i ++) { | |
style = worksheet.getCells().getColumns().get(i).getStyle(); | |
style.setLocked(false); | |
flag = new StyleFlag(); | |
flag.setLocked(true); | |
worksheet.getCells().getColumns().get(i).applyStyle(style, flag); | |
} | |
// Get the first column style. | |
style = worksheet.getCells().getColumns().get(0).getStyle(); | |
// Lock it. | |
style.setLocked(true); | |
// Instantiate the flag. | |
flag = new StyleFlag(); | |
// Set the lock setting. | |
flag.setLocked(true); | |
// Apply the style to the first column. | |
worksheet.getCells().getColumns().get(0).applyStyle(style, flag); | |
workbook.save(filePath + File.separator + "ProtectAColumn_Out.xls", FileFormatType.EXCEL_97_TO_2003); | |
} catch (Exception e) { | |
Log.e(TAG, "Protect A Column", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
// Create a new workbook. | |
Workbook workbook = new Workbook(); | |
//Accessing the first worksheet in the Excel file | |
WorksheetCollection worksheets = workbook.getWorksheets(); | |
Worksheet worksheet = worksheets.get(0); | |
// Define the style object. | |
Style style; | |
// Define the styleflag object. | |
StyleFlag flag; | |
// Loop through all the columns in the worksheet and unlock them. | |
for(int i = 0; i <= 255; i ++) { | |
style = worksheet.getCells().getColumns().get(i).getStyle(); | |
style.setLocked(false); | |
flag = new StyleFlag(); | |
flag.setLocked(true); | |
worksheet.getCells().getColumns().get(i).applyStyle(style, flag); | |
} | |
// Get the first row style. | |
style = worksheet.getCells().getRows().get(0).getStyle(); | |
// Lock it. | |
style.setLocked(true); | |
// Instantiate the flag. | |
flag = new StyleFlag(); | |
// Set the lock setting. | |
flag.setLocked(true); | |
// Apply the style to the first row. | |
worksheet.getCells().getRows().get(0).applyStyle(style, flag); | |
workbook.save(filePath + File.separator + "ProtectARow_Out.xls", FileFormatType.EXCEL_97_TO_2003); | |
} catch (Exception e) { | |
Log.e(TAG, "Protect A Row", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
//Instantiating a Workbook object | |
Workbook workbook = new Workbook(filePath + File.separator + "Book1.xls"); | |
//Accessing the first worksheet in the Excel file | |
WorksheetCollection worksheets = workbook.getWorksheets(); | |
Worksheet worksheet = worksheets.get(0); | |
Protection protection = worksheet.getProtection(); | |
//The following 3 methods are only for Excel 2000 and earlier formats | |
protection.setAllowEditingContent(false); | |
protection.setAllowEditingObject(false); | |
protection.setAllowEditingScenario(false); | |
//Protects the first worksheet with a password "1234" | |
protection.setPassword("1234"); | |
workbook.save(filePath + File.separator + "ProtectAWorksheet_Out.xls"); | |
} catch (Exception e) { | |
Log.e(TAG, "Protect a Worksheet", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
String root = Environment.getExternalStorageDirectory().toString(); | |
File myDir = new File(root + File.separator + "Aspose"); | |
String filePath = myDir.getCanonicalPath(); | |
// Create a new workbook. | |
Workbook workbook = new Workbook(); | |
//Accessing the first worksheet in the Excel file | |
WorksheetCollection worksheets = workbook.getWorksheets(); | |
Worksheet worksheet = worksheets.get(0); | |
// Define the style object. | |
Style style; | |
// Loop through all the columns in the worksheet and unlock them. | |
for(int i = 0; i <= 255; i ++) { | |
style = worksheet.getCells().getColumns().get(i).getStyle(); | |
style.setLocked(false); | |
worksheet.getCells().getColumns().get(i).applyStyle(style, new StyleFlag()); | |
} | |
// Lock the three cells...i.e. A1, B1, C1. | |
style = worksheet.getCells().get("A1").getStyle(); | |
style.setLocked(true); | |
worksheet.getCells().get("A1").setStyle(style); | |
style = worksheet.getCells().get("B1").getStyle(); | |
style.setLocked(true); | |
worksheet.getCells().get("B1").setStyle(style); | |
style = worksheet.getCells().get("C1").getStyle(); | |
style.setLocked(true); | |
worksheet.getCells().get("C1").setStyle(style); | |
workbook.save(filePath + File.separator + "ProtectCells_Out.xls", FileFormatType.EXCEL_97_TO_2003); | |
} catch (Exception e) { | |
Log.e(TAG, "Protect Cells", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
//Instantiating a Workbook object | |
Workbook workbook = new Workbook(); | |
WorksheetCollection worksheets = workbook.getWorksheets(); | |
Worksheet worksheet = worksheets.get(0); | |
Protection protection = worksheet.getProtection(); | |
//The following 3 methods are only for Excel 2000 and earlier formats | |
protection.setAllowEditingContent(false); | |
protection.setAllowEditingObject(false); | |
protection.setAllowEditingScenario(false); | |
//Protects the first worksheet with a password | |
protection.setPassword("password"); | |
//Un protecting the worksheet with a password | |
worksheet.unprotect("password"); | |
} catch (Exception e) { | |
Log.e(TAG, "Unprotect a Password Protected Worksheet", e); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Android | |
try { | |
//Instantiating a Workbook object | |
Workbook workbook = new Workbook(); | |
WorksheetCollection worksheets = workbook.getWorksheets(); | |
Worksheet worksheet = worksheets.get(0); | |
Protection protection = worksheet.getProtection(); | |
//The following 3 methods are only for Excel 2000 and earlier formats | |
protection.setAllowEditingContent(false); | |
protection.setAllowEditingObject(false); | |
protection.setAllowEditingScenario(false); | |
//Un protecting the worksheet | |
worksheet.unprotect(); | |
} catch (Exception e) { | |
Log.e(TAG, "Unprotect a Simply Protected Worksheet", e); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment