Spire.XLS is a professional Excel API that enables developers to create, manage, manipulate, convert and print Excel worksheets. Get free and professional technical support for Spire.XLS for .NET, Java, Android, C++, Python.

Sun Mar 17, 2024 4:46 pm

Hi!
I've opened csv file, and created date filter
i need remove current day, and empty cells, but filter don't work
also
cells format don't change.
Code: Select all
 File file = fileChooser.showOpenDialog(new Stage());
        file.getAbsoluteFile();
        fileError = String.valueOf(file);
        Workbook wb = new Workbook();
        wb.loadFromFile(fileError, ",", 1, 1);
        Worksheet sheet = wb.getWorksheets().get(0);
        int lastRow = sheet.getLastRow();
        sheet.getCellRange("A1:V" + lastRow).setIgnoreErrorOptions(EnumSet.of(IgnoreErrorType.NumberAsText));
        CellRange range = sheet.getCellRange("M1:M" + lastRow);
        range.setNumberFormat("dd.mm.yyyy");
        //Перенос текста по столбцам и применение автофильтра
        AutoFiltersCollection filters = sheet.getAutoFilters();
        filters.setRange(sheet.getCellRange(1, 1, lastRow, 22));
        //Фильтр колонки "Статус"
        //filters.addFilter(6, "Сформирован");
        //Фильтр колонки "Завершили формирование"
        if (currentDate == null) {
            currentDate = LocalDate.now();
        }
        filters.customFilter(12, FilterOperatorType.NotEqual, currentDate, true, FilterOperatorType.NotEqual, "");
        filters.filter();

        wb.saveToFile("C:\\Users\\" + user + "\\Desktop\\Ошибки\\503.xlsx");

SerPivas
 
Posts: 13
Joined: Wed Jan 03, 2024 4:51 pm

Mon Mar 18, 2024 8:42 am

Hello,

Thanks for your inquiry.
To help us further investigate your issue, please provide us with your CSV file, you can upload it here as an attachment or send it to this email address: support@e-iceblue.com. Thank you in advance.

Sincerely,
William
E-iceblue support team
User avatar

William.Zhang
 
Posts: 203
Joined: Mon Dec 27, 2021 2:23 am

Mon Mar 18, 2024 9:37 am

Unfortunately, i can't do that
cuz this file from my work
it's forbidden.

SerPivas
 
Posts: 13
Joined: Wed Jan 03, 2024 4:51 pm

Tue Mar 19, 2024 5:49 am

Hello,

Thanks for your reply.
Sorry, if you cannot provide the documents, it will be difficult for us to further investigate. You can remove key information from the document and send it to this email: support@e-iceblue.com. We will keep your documents confidential. Thank you for your understanding.

Sincerely,
William
E-iceblue support team
User avatar

William.Zhang
 
Posts: 203
Joined: Mon Dec 27, 2021 2:23 am

Tue Mar 19, 2024 7:37 am

I can't remove key information
Cuz it's csv file
And it contains a lot of information
If i delete some value, formatting file will be incorrect
Anyway
All information is key

SerPivas
 
Posts: 13
Joined: Wed Jan 03, 2024 4:51 pm

Tue Mar 19, 2024 8:56 am

Hello,

Thanks for your reply.
Sorry, regarding the issue you mentioned, we cannot further investigate without the source file. Could you please simulate a document based on your source file and provide it to us? Thanks for your understanding.

Sincerely,
William
E-iceblue support team
User avatar

William.Zhang
 
Posts: 203
Joined: Mon Dec 27, 2021 2:23 am

Wed Mar 20, 2024 8:43 am

I need to remove today (20.03.2024), yesterday (19.03.2024)
and empty cells in the column "Завершили формирование"
Column "Статус" must be "Сформирован"
Attachments
503.7z
(260 Bytes) Downloaded 28 times

SerPivas
 
Posts: 13
Joined: Wed Jan 03, 2024 4:51 pm

Thu Mar 21, 2024 9:18 am

Hello,

Thanks for your file.
I created a filter using Our Spire.Xls to test your case, and I found that it did not work. I have logged this issue in our tracking system with ticket number SPIREXLS-5178. Our development team will further investigate and I will inform you promptly of any progress. Sorry for any inconvenience caused to you.

Sincerely,
William
E-iceblue support team
User avatar

William.Zhang
 
Posts: 203
Joined: Mon Dec 27, 2021 2:23 am

Fri Mar 22, 2024 4:39 am

Thanks
I'll be waiting

SerPivas
 
Posts: 13
Joined: Wed Jan 03, 2024 4:51 pm

Fri Mar 29, 2024 9:36 am

Hello,

Thanks for your patience.
Regarding the issue SPIREXLS-5178, our development team did further investigation. They point out that LocalDate is a class in Java8, but our product is compiled on java6. Therefore, when using a custom filter, you cannot pass a LocalDate object, and you need to replace it with a string in date format. Based on your previous requirements, do not keep today and yesterday's dates, and do not keep empty cells. We suggest that you set the condition of the filter to be less than before yesterday. The code is as follow:
Code: Select all
String localDate1 = "2024/3/19 21:46";
sheet.getAutoFilters().customFilter(filterColumn,  FilterOperatorType.LessThan, localDate1,true,FilterOperatorType.None,null);

If you have any further questions, please feel free to write to us at any time.

Sincerely,
William
E-iceblue support team
User avatar

William.Zhang
 
Posts: 203
Joined: Mon Dec 27, 2021 2:23 am

Mon Apr 01, 2024 8:58 am

Hello.
Your code is not working
All cells is empty
Your code.png
Your code.png (4.29 KiB) Viewed 1508 times

But i've tried do this
Code: Select all
String localDate = "2024-3-30";
filters.customFilter(14, FilterOperatorType.LessThan,localDate,true,FilterOperatorType.NotEqual,"");

And empty cells are gone
But all date 2024.03.31still here
My code.png
My code.png (20.01 KiB) Viewed 1508 times

SerPivas
 
Posts: 13
Joined: Wed Jan 03, 2024 4:51 pm

Mon Apr 01, 2024 9:59 am

Hello,

Thanks for your reply.
Please refer to the complete code below for testing. If your issue still exists, please provide us with your current testing file and we will further investigate. Thank you in advance.
Code: Select all
Workbook workbook = new Workbook();
workbook.loadFromFile("test.xlsx");
Worksheet sheet = workbook.getWorksheets().get(0);
sheet.getAutoFilters().setRange(sheet.getCellRange(1,1,sheet.getLastDataRow(),sheet.getLastDataColumn()));
FilterColumn filterColumn = sheet.getAutoFilters().get(0);
String localDate = "2024-3-30";
sheet.getAutoFilters().customFilter(filterColumn, FilterOperatorType.LessThan,localDate,true,FilterOperatorType.None,null);
sheet.getAutoFilters().filter();
workbook.saveToFile("result.xlsx", ExcelVersion.Version2013);

Sincerely,
William
E-iceblue support team
User avatar

William.Zhang
 
Posts: 203
Joined: Mon Dec 27, 2021 2:23 am

Return to Spire.XLS