Chart colors change when I copy a worksheet

Hello!
When I copy a worksheet from one workbook to separate, new workbook, the colors of the charts change. Is there a way to prevent this?
Below is an example: the first photo is the original worksheet that I am trying to copy. The second photo is the copied worksheet that appears in the new workbook.

Screenshot 2025-02-21 at 6.39.22 PM.jpg (189.1 KB)

Screenshot 2025-02-21 at 6.39.14 PM.png (266.4 KB)

@jamieMacabacus Hello, may I ask what code environment and API you are using to perform this operation? If possible, could you provide the code and a sample Excel file so that we can reproduce and resolve this issue.

Hi!
I am using the python sdk (version 25.1.1). Here is some sample code that will allow you to reproduce the problem. Attached is the input file I am trying to copy and the output file that is the result of the copying.

input.xlsx.zip (11.6 KB)
output.xlsx.zip (11.4 KB)

from asposecellscloud import CellsApi
from asposecellscloud.models import *
from asposecellscloud.requests import *


STORAGE = "Dev Internal Storage"
cells_api = CellsApi(ASPOSE_CLIENT_ID, ASPOSE_CLIENT_SECRET)


def main():
    try:
        local_file = "input.xlsx"
        local_path = "input/" + local_file

        aspose_folder = "output"
        aspose_file_name = "aspose_chart.xlsx"

        target_sheet = "sample_sheet"

        request = UploadFileRequest(
            upload_files=[local_path],
            path=f"{aspose_folder}/{aspose_file_name}",
            storage_name=STORAGE,
        )
        cells_api.upload_file(request)

        print("Uploaded file")

        new_workbook_name = "output.xlsx"
        request = PutWorkbookCreateRequest(
            name=new_workbook_name,
            folder=aspose_folder,
            storage_name=STORAGE,
        )
        cells_api.put_workbook_create(request)

        print("Created new workbook")

        copy_options = {
            "ColumnCharacterWidth": True,
            "CopyInvalidFormulasAsValues": True,
            "CopyNames": True,
            "ExtendToAdjacentRange": True,
            "ReferToDestinationSheet": True,
            "ReferToSheetWithSameName": True,
        }
        request = PostCopyWorksheetRequest(
            name=new_workbook_name,
            sheet_name=target_sheet,
            options=copy_options,
            source_sheet=target_sheet,
            source_workbook=aspose_file_name,
            source_folder=aspose_folder,
            folder=aspose_folder,
            storage_name=STORAGE,
        )
        cells_api.post_copy_worksheet(request)
    except Exception as e:
        print(e)


if __name__ == "__main__":
    print("Starting...")
    main()

@jamieMacabacus we will check why this problem occurs.

1 Like

@jamieMacabacus You can try to use Convert to meet your needs. Convert can only convert one worksheet. If out_path is specified, the corresponding file will be generated on the cloud storage. You can download the file or if there is no out_put value, the data stream will be returned.
This is the reference code:

 local_name = '25720.xlsx'
       
        mapFiles = { 
            local_name: os.path.dirname(os.path.realpath(__file__)) + "\\TestData\\" +local_name             
        }
    
        request =  PutConvertWorkbookRequest( mapFiles,format= 'xlsx',sheet_name='sample_sheet' , out_path='25720sample_sheet.xlsx')
        self.api.put_convert_workbook(request)

If you have other questions, feel free to ask.

Awesome, that worked. Thank you!

@jamieMacabacus,

Thank you for using our products. If we can meet any of your needs, we will integrate them for you as much as possible.