Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rgba(255 is not a valid value for Int32 #55

Open
danvic712 opened this issue May 7, 2019 · 24 comments
Open

rgba(255 is not a valid value for Int32 #55

danvic712 opened this issue May 7, 2019 · 24 comments

Comments

@danvic712
Copy link

I want to put an html string to a workbook cell (with some html element contains rgba in css style) ,and then I use HtmlString, but this operate throw a error about rgba(255 is not a valid value for Int32
The version I have using is Aspose.Cells 19.4.0

//Datatable data

for (int i = 0; i < rows; i++)
{
    for (int k = 0; k < columns; k++)
    {
        cells[1 + i, k].HtmlString = data.Rows[i][k].ToString();
        cells[1 + i, k].SetStyle(style);
    }
}       
@amjad-sahi
Copy link
Collaborator

I think you should debug your code closely for the datatable field value(s) if it is ok, the issue may lie there. I have tested using the following code with static HTML string, it works fine and I do not find any issue. See the sample code that I am using:
e.g
Sample code:

Workbook wb = new Workbook();

            Worksheet ws = wb.Worksheets[0];

            Cell cell = ws.Cells["B5"];
            cell.HtmlString = "<p>This is what a bio <span style=\"color:rgb(255, 0, 0)\">teacher </span>does....lots of <span style=\"background-color:rgb(255, 215, 0)\">stuff</span>.</p> <ol> <li>You must be smart</li> <li><a href=\"http://www.google.com\">Patient</a></li> <li>Can type&nbsp;</li> <li>other stuffs.</li> </ol>";

            wb.Save("e:\\test2\\out1.xlsx");

If you still could not evaluate or find the issue, kindly do provide sample code (runnable) same as above, you may use static string or create dynamic Dataset/datatable in code to remove any inter-dependencies for external data sources to show the issue, so we could execute your code precisely to consequently figure it out soon.

@danvic712
Copy link
Author

@amjad-sahi
Hi, Here is my sample code, I tried html string which has rgb color model and that is fine , but when the html string has rgba color, and is still throw error

static void Main(string[] args)
{
    Workbook wb = new Workbook();
    Worksheet ws = wb.Worksheets[0];

    Cell cell = ws.Cells["B5"];
    cell.HtmlString = "<span style='background-color: rgba(255, 255, 255, 0.8);'>lalalalalala</span>";

    wb.Save(@"C:\Users\danvic.wang\Desktop\demo.xlsx");
}

20190507162522

@amjad-sahi
Copy link
Collaborator

@Lanesra712

Thanks for the code segment and screenshot with details.

After an initial test, I am able to observe the issue as you mentioned by using updated sample code. I found an exception "rgba(255 is not a valid value for Int32" when setting HTML string using rgba color model, it works fine if I use rgb instead:
e.g
Sample code:

Workbook wb = new Workbook();

 Worksheet ws = wb.Worksheets[0];

 Cell cell = ws.Cells["B5"];
//This works.            
//cell.HtmlString = "<p>This is what a bio <span style=\"color:rgb(255, 0, 0)\">teacher </span>does....lots of <span style=\"background-color:rgb(255, 215, 0)\">stuff</span>.</p> <ol> <li>You must be smart</li> <li><a href=\"http://www.google.com\">Patient</a></li> <li>Can type&nbsp;</li> <li>other stuffs.</li> </ol>";
//This does not work            
cell.HtmlString = "<span style='background-color: rgba(255, 255, 255, 0.8);'>lalalalalala</span>";

  wb.Save("e:\\test2\\out1.xlsx");

I have logged a ticket with an id "CELLSNET-46719" for your issue. We will look into it to figure it out soon. It is possible that we will share the fix which may fix your issue.

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

@danvic712
Copy link
Author

@amjad-sahi
Thanks a lot 😄

@ahsaniqbalsidiqui
Copy link
Collaborator

@Lanesra712

This is to inform you that we have fixed your issue (logged earlier as “CELLSNET-46719”) now. We will soon provide you the fixed version after performing QA and incorporating other enhancements and fixes.

@danvic712
Copy link
Author

@ahsaniqbalsidiqui
Thanks~~~

@ahsaniqbalsidiqui
Copy link
Collaborator

@Lanesra712
Please try our latest version/fix: Aspose.Cells for .NET v19.4.5 (attached)

Your issue should be fixed in it.

Let us know your feedback.
Aspose.Cells19.4.5 For .Net2_AuthenticodeSigned.Zip
Aspose.Cells19.4.5 For .Net4.0.Zip

@danvic712
Copy link
Author

@ahsaniqbalsidiqui
Hi,thanks for hard working, I download it and add it to my demo project, unfortunately it seems still have this bug, here is my demo, thanks.
Demo address:aspose demo

@amjad-sahi
Copy link
Collaborator

@Lanesra712

Thanks for the demo project.

Please ignore our previous reply as the shared fix does not include your fix in it. We will share a hotfix in the next week (hopefully) which will figure out your issue.

Keep in touch.

@amjad-sahi
Copy link
Collaborator

@Lanesra712,

Please try our latest version/fix: Aspose.Cells for .NET v19.4.6 (attached)

Your issue should be fixed in it.

Let us know your feedback.
Aspose.Cells19.4.6 For .Net2_AuthenticodeSigned.Zip
Aspose.Cells19.4.6 For .Net4.0.Zip

@danvic712
Copy link
Author

@amjad-sahi
Thanks for hard working, this issue has been resolved , thanks

@amjad-sahi
Copy link
Collaborator

@Lanesra712,

Good to know that your issue is resolved with the new fix/version. Feel free to contact us any time if you have further queries or issue, we will be happy to assist you soon.

@BinodPanditJH
Copy link

BinodPanditJH commented Sep 13, 2022

How i can do specific cell format using coding .please help

@amjad-sahi
Copy link
Collaborator

@BinodPanditJH,

See the following sample code on how to format (apply background color, change font with color and do alignment, etc.) a cell in the worksheet for your reference:
e.g.
Sample code:

//Create a new workbook
Workbook workbook = new Workbook();
//Get the first(default) worksheet in the workbook
Worksheet SheetReport = workbook.Worksheets[0];

//Get the A1 cell
Cell cell = SheetReport.Cells["A1"];
//Insert a value
cell.PutValue("testin..");
// Create and specify style object
Style cellStyle = new CellsFactory().CreateStyle();
cellStyle.HorizontalAlignment = TextAlignmentType.Left;
cellStyle.VerticalAlignment = TextAlignmentType.Center;
cellStyle.Pattern = BackgroundType.Solid;
cellStyle.ForegroundColor = Color.Red;
// Sets Cell style font attributes
cellStyle.Font.Name = "Arial";
cellStyle.Font.IsBold = true;
cellStyle.Font.Size = 12;
cellStyle.Font.Color = Color.Yellow;

// Apply the style to the cell
cell.SetStyle(cellStyle);

//Save the Excel file
workbook.Save("e:\\test2\\out1.xlsx");

Moreover, please see the documents with examples on Format Cells for your complete reference.

Should you have further queries or issue, feel free to contact us in dedicated forums.

@BinodPanditJH
Copy link

Thanks

@BinodPanditJH
Copy link

How to find range like eg . Range[A5,A10]?

@amjad-sahi
Copy link
Collaborator

@BinodPanditJH ,

See the document on managing ranges for your reference.

We encourage you to try using our dedicated forums for your further queries or issue. We handle clients queries efficiently in the forums.

@amjad-sahi amjad-sahi reopened this Sep 19, 2022
@amjad-sahi
Copy link
Collaborator

amjad-sahi commented Sep 19, 2022

@BinodPanditJH ,

How to remove green mark on cell

If the numeric data is inserted as string, you will see green triangle saying “Number stored as text” on top left corner of the cell(s). Please note, to apply proper formatting or perform calculations upon the cells, you need to convert these string values (in the cells) to numeric values. Otherwise you will not be able to set your desired tasks.

You may use overloaded version of the method, e.g., Cell.PutValue(string stringvalue, bool isConverted) to convert each cells’ existing value (if possible) to numeric values, set the last argument to true. I think you may loop through all those cells in the column and use this overloaded version of the method to convert every possible string value to numeric value (if possible) for the same cell.
e.g.,
Sample code:

 ...............
      cell.PutValue(cell.StringValue, true);
......................

Hope, this helps a bit.

@BinodPanditJH
Copy link

Thanks amjad-sahi

@amjad-sahi
Copy link
Collaborator

@BinodPanditJH,

You are welcome.

@BinodPanditJH
Copy link

How to row and column hide?

@amjad-sahi
Copy link
Collaborator

amjad-sahi commented Sep 26, 2022

@BinodPanditJH,

You can hide a row or column by using the HideRow and HideColumn methods of the Cells collection respectively. Both methods take the row and column index as a parameter to hide the specific row or column.

e.g.
Sample code:

// Instantiating a Workbook object
// Opening the Excel file through the filepath
Workbook workbook = new Workbook("Book1.xlsx");

// Accessing the first worksheet in the Excel file
Worksheet worksheet = workbook.Worksheets[0];

// Hiding the 3rd row of the worksheet
worksheet.Cells.HideRow(2);

// Hiding the 2nd column of the worksheet
worksheet.Cells.HideColumn(1);

// Saving the modified Excel file
workbook.Save("out1.xlsx");

Please note, it is also possible to hide a row or column by setting the row height or column width to 0 respectively via relevant API.

Moreover, you can show/unhide any hidden row or column by using the UnhideRow and UnhideColumn methods of the Cells collection respectively.

Hope, this helps a bit.

We again ask you to use our dedicated forums for your queries or issue where we handle clients queries or issues efficiently.

@BinodPanditJH
Copy link

How to merge A and B column ? I want to used Colspan ,How to use???
Pls help

@amjad-sahi
Copy link
Collaborator

amjad-sahi commented Dec 13, 2022

@BinodPanditJH,

See the document on merging cells for your reference. Also, see the topic for further reference.
https://kb.aspose.com/cells/net/how-to-merge-cells-in-excel-using-csharp/

I want to used Colspan ,How to use???

Do you want to set HTML string to the cell, so it should be parsed and cells are merged automatically? If true, you may use Cell.HtmlString attribute to specify your desired HTML string to the cell. If not, kindly elaborate it on how you could implement merging cells in MS Excel manually, you may provide sample Excel file with your desired results. We will check and help you on how to do it via Aspose.Cells APIs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants