We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Change chars type


Im testing your great tool Aspose.Cells, Im working with a chars, I make a chars using your guide documentation, i have a normal chars (look chars-1.png image), excel have some predefined style (look chars-2.png image), would like know how I can change the style of my chars using your code, if have any sample, for set style 6.
thank you for your responsechars-1.png (20.7 KB)
chars-2.png (165.3 KB)


Thanks for the screenshots.

Please use the Chart.Style property to set the style of the chart. Please see the following sample code that explains how to make use of this property.
Sample code:

string filePath = "e:\\test2\\source.xlsx";

Workbook workbook = new Workbook(filePath);

Worksheet worksheet = workbook.Worksheets[0];

Chart chart = worksheet.Charts[0];

chart.Style = 6;


Hope, this helps a bit.


thanks for the reply

on my code I set it but not change
maybe need change other features …
chars-4.png (27.0 KB)
chars-3.png (35.7 KB)


Thanks for the screenshots.

Could you provide us template file(s) and sample code (runnable) to show the issue, we will check it soon.

here template original, and the needed format, the code used for change type chars is the code to you publish. openig exist file, I also use on the code when create chars, but on both not work.
thank you
test.zip (18.0 KB)


Thanks for the the sample files. We will check and get back to you soon.


Thanks for the template file.

After an initial test, I am able to observe the issue as you mentioned by using the following sample code with your template file. I found that chart style is not changed in the template file:
Sample code:

string filePath = "e:\\test2\\test.xlsx"; 
            Workbook workbook = new Workbook(filePath); 
            Worksheet worksheet = workbook.Worksheets[0]; 
            Chart chart = worksheet.Charts[0]; 
            chart.Style = 6; 

I have logged a ticket with an id “CELLSNET-46346” for your issue. We will look into it soon.

Once we have an update on it, we will let you know here.

thank you very much for your help


You are welcome.

hi, sorry can you help me on other problem with Charts

Im making a Charts style gradiant fill, here attach the details,

thanksbbh.zip (20.2 KB)
gradient-3.png (74.0 KB)
gradient-1.png (125.8 KB)
gradient-2.png (118.5 KB)


Thank you for contacting us again.

You may please send us a simplified console application (runnable) which can be executed here to re-produce the scenario. Also send us the expected output file created by Excel for our comparison.

thank you for your response

I found the solution with this code

chart.ChartArea.Area.FillFormat.GradientFill.GradientStops(2).CellsColor.ThemeColor = New ThemeColor(ThemeColorType.Accent6, 0.4)

thanks for your help

I will wait can solve the problem on style of chart



You are welcome.


Sorry I need your help for a little problem

I need get a collections cells of a range for example “A1:AL15”
I check your code, and Worksheet.cells provide all cells on Worksheet.
then I need only cells for a range, and also can get list of MergedCells on the range
is possible it?, can provide a sample, please

Thank you


Thanks for your query. We are working on it and will provide our feedback soon.


Thanks for your query.

You may try following sample code which provides the cells information in a range.

// Instantiate a new Workbook.
Workbook workbook = new Workbook();

// Get the first worksheet in the book.
Worksheet WS = workbook.Worksheets[0];

// Create a range of cells.
Aspose.Cells.Range range = WS.Cells.CreateRange(1, 1, 5, 5);

//Get the first row, first column and total rows and counts in the range
Console.WriteLine( range.RowCount);
// Save the excel file.

Following sample code can be used to detect merged cells and provides information about the cells in the merged cells range. Please give it a try and share the feedback.

// Instantiate a new Workbook - Open an existing excel file
Workbook wkBook = new Workbook(sourceDir + "sampleDetectMergedCellsAndUnmerge.xlsx");

// Get a worksheet in the workbook
Worksheet wkSheet = wkBook.Worksheets["Sheet1"];

// Create an arraylist object
ArrayList al = new ArrayList();

// Get the merged cells list to put it into the arraylist object
al = wkSheet.Cells.MergedCells;

// Define cellarea
CellArea ca;

// Define some variables
int frow, fcol, erow, ecol, trows, tcols;

// Loop through the arraylist and get each cellarea to unmerge it
for (int i = 0; i < al.Count; i++)
	ca = new CellArea();
	ca = (CellArea)al[i];
	frow = ca.StartRow;
	fcol = ca.StartColumn;
	erow = ca.EndRow;
	ecol = ca.EndColumn;

	trows = erow - frow + 1;
	tcols = ecol - fcol + 1;
	wkSheet.Cells.UnMerge(frow, fcol, trows, tcols);

// Save the excel file
wkBook.Save(outputDir + "outputDetectMergedCellsAndUnmerge.xlsx");

sampleDetectMergedCellsAndUnmerge.zip (6.8 KB)

thank you very much for your reply, I check it, maybe I not explain good my question

I ask if your code have any function or method, for get the list of merged cells on a range
for example, will be excellent can do it

'Instantiate a new Workbook.
dim workbook as Workbook = new Workbook()

'Get the first worksheet in the book.
dim WS as Worksheet = workbook.Worksheets(0)

'Create a range of cells.
dim range as Aspose.Cells.Range = WS.Cells.CreateRange(“A1:T20”)

dim merged = range.MergedCells()

this option can be extended for put format on the cells, for example


'or also

also can be better use this range for put borders, and other things.

will be very good can do it on your code

thanks for your help



It seems that this functionality is already there in Aspose.Cells by parsing each cell in the range and checking IsMerged and GetMErgedRange() similar to the concept in the following sample code:

Workbook wb = new Workbook(“book1.xlsx”);
var cells = wb.Worksheets[0].Cells;
foreach(Cell cell in cells)
if (cell.IsMerged)
var range = cell.GetMergedRange();

Similarly for styles part of your query please use Range.ApplyStyle() feature and provide your feedback.

thank you very much for your response

have any code for get the Cellarea of merged cell, or convert mergedrange to cellarea


I am afraid that no direct method is available to convert cell area to merged cells and vice versa. You may please write own logic to achieve this functionality.