Code Monkey home page Code Monkey logo

Comments (12)

Bobolovewill avatar Bobolovewill commented on August 15, 2024 3

Thank you and everyone for your generous answers, will continue to support onlyoffice, you can close this now, good luck!

from onlyoffice.github.io.

kirodzumy avatar kirodzumy commented on August 15, 2024 1

@AlexeyMatveev686 thank you

from onlyoffice.github.io.

ShockwaveNN avatar ShockwaveNN commented on August 15, 2024

@askonev Please take a look

from onlyoffice.github.io.

AlexeyMatveev686 avatar AlexeyMatveev686 commented on August 15, 2024

et.getRange(color

Hello, let me help you.

You can use this macros for your task:

function CountColoredCells (Range1, Range2)
{
// Range1 is the range where the search will be performed
// Range2 is the range to be compared with when searching
// (if there is more than one cell, it will only be compared with the first one)
var count = 0;
var color = Range2.GetFillColor();
if (color !== "No Fill") {
Range1.ForEach(function(cell) {
var curColor = cell.GetFillColor();
if (curColor !== "No Fill" && curColor.color === color.color)
count++;
});
}
return count;
}

Also you can can check how it works in my example file.
Good luck!
new (1).xlsx

from onlyoffice.github.io.

Bobolovewill avatar Bobolovewill commented on August 15, 2024

Sorry, just replied. I still get an error after following your method of testing
8P8H_YY98VNFDWSTE1TV4
.
(70P85ELR7S4 Q72ZHV_CKS

from onlyoffice.github.io.

askonev avatar askonev commented on August 15, 2024

@Bobolovewill Hi!

Please specify the version of the product on which you run the script.

from onlyoffice.github.io.

Bobolovewill avatar Bobolovewill commented on August 15, 2024

@Bobolovewill嗨!

请指定运行脚本的产品版本。

Version: 5.6.5 (build:3)

from onlyoffice.github.io.

ShockwaveNN avatar ShockwaveNN commented on August 15, 2024

@Bobolovewill This is very very old version. Please update to current v6.4.2 and see if problems persists

from onlyoffice.github.io.

Bobolovewill avatar Bobolovewill commented on August 15, 2024

@Bobolovewill This is very very old version. Please update to current v6.4.2 and see if problems persists

Sorry for just replying, thanks everyone. The function worked after the upgrade, but I can't call it anywhere, I have to write it in advance. Last question, how to run macros automatically, or is there a shortcut?

from onlyoffice.github.io.

ShockwaveNN avatar ShockwaveNN commented on August 15, 2024

run macros automatically, or is there a shortcut

We got autorun button:
image
And marcos settings:
image

Not sure how it works, not my area

Also, you can convert your macros to plugin (it use same code, but require some additional metadata) - you can run plugin with autostart

from onlyoffice.github.io.

kirodzumy avatar kirodzumy commented on August 15, 2024

@ShockwaveNN Unfortunately, this macro does not work on version 7.5.1, could you please update it?

from onlyoffice.github.io.

AlexeyMatveev686 avatar AlexeyMatveev686 commented on August 15, 2024

@ShockwaveNN Unfortunately, this macro does not work on version 7.5.1, could you please update it?

Hello. If you use example whitch I posted you should add "var" before "oWorksheet" variable into the 3-th line. I've checked this macros, it works fine in 7.5.1 after this changes. Here is new macros:

(function()
{
    var oWorksheet = Api.GetActiveSheet();
    // the ranges where the search will be performed
    var Range1 = oWorksheet.GetRange("A1:B14");
    var Range2 = oWorksheet.GetRange("B1:B7");
    // the range to be compared with when searching
    // (if there is more than one cell, it will only be compared with the first one)
    var Range3 = oWorksheet.GetRange("D1");
    var Range4 = oWorksheet.GetRange("D1");
    var Range5 = oWorksheet.GetRange("D2");
    var count  = CountColoredCells(Range1, Range3);
    var count2 = CountColoredCells(Range2, Range4);
    var count3 = CountColoredCells(Range1, Range5);
    oWorksheet.GetRange("E1").SetValue("D1 in A1:B14 = " + count);
    oWorksheet.GetRange("E2").SetValue("D1 in B1:B7 = " + count2);
    oWorksheet.GetRange("E3").SetValue("D2 in A1:B14 = " +count3);
  
    function CountColoredCells (Range1, Range2)
    {
        // Range1 is the range where the search will be performed
        // Range2 is the range to be compared with when searching
        // (if there is more than one cell, it will only be compared with the first one)
        var count = 0;
        var color = Range2.GetFillColor();
        if (color !== "No Fill") {
            Range1.ForEach(function(cell) {
                var curColor = cell.GetFillColor();
                if (curColor !== "No Fill" && curColor.color === color.color)
                    count++;
            });
        }
        return count;
    }
    
})();

from onlyoffice.github.io.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.