RDLC exported to excel to show negative numbers in parentheses - c#

I have an rdlc file with cells showing decimals.
How do I convert a negative number to have parenthesis?
I can't display it as a string, because when the report is exported it treats in as a string and throws an error that the number could not convert a string.
I've tried adding #,0:c0 for the format property but this didn't work.
Any suggestions?

Try to not use the Format function in the Expression of your Placeholder, instead in the text box (or cell) properties, you can set the type and the format of it.
In the properties, there is a section called Number in which you specify that the textbox must contains numbers of a specificated category.
Here is an image to explain:
As you can see, there is an option to set how to display negative numbers (the one selected).
Now, I'm sure that this will works if you export the report in PDF but I hope this will be the same for Excel's export

I worked it out, sorry to answer my own question.
if I use the following in the format property #,0;(-#,0) it works fine.

In my case below custom expression solved my problem.
''#,0.00;''(#,0.00);

Related

Visual Studio Incorrectly Displays Barcode Font In RDLC Reports

I have the following issue: I have a windows form app where I print reports and they are supposed to have barcodes on them. When I am in the .rdlc file designer the barcode shows like this:
(The weird crossed out circles I assume is from the square brackets and the # symbol because data is coming from a parameter).
So when I print this out, everything prints out fine, but the thing is, the barcode font I am using is supposed to also have text underneath like this:
Now when I go into Word and type in the same barcode font (I triple checked it is the same) it behaves as expected
I looked all over the place but there are literally no posts anywhere that I could find that would help me besides this one by Microsoft It just tells me I need that .dll file but I already have it and still same results.
UPDATE: so the other report that also has barcodes works just fine, the barcodes that work are: *1868210325S0000100004* , *S00001+000001+00004+FIEG0P01* , *EDG20210325000374570*
barcode that does NOT work: *JLI-0253932*
it takes the value from a parameter "liNumber" which is populated like so:
parameters[6] = new ReportParameter("liNumber", "J" + fidelity.liNumber, true);
where fidelity.liNumber returns LI-0253932
But what I don't understand is that all working barcodes are populated in a similar fashion
Most of the times I have run into that, it was due to data. Barcode fonts may not have value for lower-case content or special characters.
I would make a copy of your report for backup, copy the detail since you have space between the detail rows. In the second instance, change the font back to a normal / simple font like Courier. Then print the report again. Check to see the ACTUAL values being printed in normal font vs your barcode font. I would bet they are upper/lower / special characters and spaces that the barcode does NOT have included in it.
Additionally, every time you run the report, write the actual values out to a text file and just keep appending text. Then, you can open the text file in Word or whatever editor, select all text, then change the font to the barcode. Do you get the same bad results.
Recreating the parameter in both .cs file like so
string jliNumber = "J" + fidelity.liNumber;
parameters[6] = new ReportParameter("liNumber", jliNumber, true);
and then in the report .rdlc file just deleting and creating the same parameter again worked for some reason

Highlight the differences in PDF using C#

I have generated the report in PDF format that compares two .DAT files and it works fine and it highlights entire rows which have differences. But now I want to highlight specific change.
Is there anyway that compares the text from pdf and highlights the differences between it???
This is the comparison in listview
This is the comparision in pdf file which highlight entire row but now I want to highlight specific change
I think you have to try character comparison,but not directly,i have done string comparison but using the replace and to lowercase method,i.e first replace space with "",and lower the strings,then you can go for character comparison,then only result would not be weird.

DataGridView Format Decimal Values with AutoGenerateColumns

I have a datagridview that uses AutoGenerateColumns in winforms. There is a date column and then 1-16 data columns containing numeric values. I want all of these 1-16 data columns to be formatted to 4 decimal places.
As per this post, you set the DefaultCellStyle through the designer. I did this manually to get what format that I want to use. I set this in the form constructor:
this.dgv_PreviewGrid.DefaultCellStyle.Format = "N4";
I have tried setting it this way and also tried manually on each column on DataBindingComplete event. Nothing happens! The app lags as though it is doing the rounding, but doesn't.
Also, is there a link to msdn or something with a list of the DefaultCellStyle formats? Couldn't find them.
EDIT: I found that using Format "D4" instead of "N4" (Decimal vs. Number) --> is probably the format that I want, but it is still not working.
The MSDN page you want is Standard Numeric Format Strings.
You want the N or F format specifier, not D. D is for integers.
Setting grid.DefaultCellStyle.Format should work, but since you have a date column you will need to override that column's DefaultCellStyle, or the dates won't display.
What is the actual type of the numeric property on your datasource? Are you sure it isn't a string? How are you populating the DataGridView?
Without more information it's difficult to guess the problem. It might help if you show the code that populates the DataGridView.

Display Autocomplete list based on a Cell Range

I'm trying to do an Excel Add-In and I would like that, in a worksheet that I'm creating, I could select a cell (or a range of cell) that, once you start typing on it (or them), a dropdown-like with possible matches for the typed characters.
Is this possible to do it programmatically?
The closest that I got to achieve this is through the Validation object of the Cell, but a dropdown-like list of options is not displayed just, as you could imagine, I get to display a message indicating that the text is not valid.
As always, thanks in advance!

Fixing number of decimals in crystal report

here is my situation. I have created a DataSet, in my projet, that is linked to my Crystal report. Howhever, when I run the application and that I look at my report, there is decimal on all of my numeric fields. How can I remove them?
For your information, when I right-click on one of these numeric field, I don't have a format option (probably because it comes from a DataSet and not directly from the DB, I can't tell exactly).
Thanks
You don't see the Format Field... option in the context menu? Is the field inside a text object? You can select the field inside the text object and get the Format Field option. Then you go to the number tab and use the Customize dialog to set the number of decimal places displayed.

Categories