ejsExcel icon indicating copy to clipboard operation
ejsExcel copied to clipboard

Can I erase a column based on a variable?

Open matepaiva opened this issue 6 years ago • 11 comments

I want to be able to evaluate a property (or an if) and delete a column, in the same way that we can delete a sheet (<%_deleteSheet_()%>). Is that possible?

matepaiva avatar Jun 25 '18 15:06 matepaiva

You can not erase a column. But you can build a new array before <%forRow or <%forCell or <%forCBegin and so on.

<% const oldArray = ["a", "b", "c"]; const buildNewArray = ["a", "c"]; %> <%forCell str in buildNewArray%><%=str%>

Otherwise, <%%> can run all javascript code. <% console.log("run javascript code"); %>

sail-sail avatar Jun 25 '18 15:06 sail-sail

The problem with that approach is that we have conditions and styles for columns that are not provided by us, but by operational team. It means, we wanted to use an template file with all usecases and just delete the columns that were not interesting for an specific usecase.


And: what is the main difficulty to implement this feature (deleteColumn())? Maybe our team could help with that. :)

matepaiva avatar Jun 25 '18 16:06 matepaiva

First, Thank you for you propose. It is very helpfull. We will think it. Second, Now, You can use VBA to implement that. Template can use all excel function include the VBA.

sail-sail avatar Jun 25 '18 16:06 sail-sail

<%_deleteSheet_()%> Can also to try. It will delete current sheet.

sail-sail avatar Jun 25 '18 16:06 sail-sail

Yep, but we need to delete only one or two columns. Otherwise we would have to create a lot of sheets to contemplate every usecase.

We are going to fork the lib to try to implement the deleteColumn, ok? And we could offer docs in english and portuguese as well, if you like.

matepaiva avatar Jun 25 '18 16:06 matepaiva

Of course OK, Thank you very much!

sail-sail avatar Jun 25 '18 16:06 sail-sail

deleteColumn change the name to deleteCell maybe better.

sail-sail avatar Jun 25 '18 16:06 sail-sail

How about shiftColumns? Because what we really need is to shift all columns one house from left to right when we delete a column.

matepaiva avatar Jun 25 '18 17:06 matepaiva

Yes, shiftCell. I Think. Column means that a whole column, so Cell will be better. Excel inside also is Cell, not Column.

sail-sail avatar Jun 25 '18 17:06 sail-sail

May I know when this 'deleteCell' can be ready? I also wanna use it. Now when I use <% if %> condition in the template, it always keep empty rows there which is not expected... :(

michellechsy avatar Dec 19 '18 10:12 michellechsy

<%ifCBegin "1"==="1"%><%="abcd--ifCBegin"%>    <%ifCEnd%>

<%ifCBegin "1"==="2"%><%="abcd--ifCBegin"%>    <%ifCEnd%>

sail-sail avatar Dec 19 '18 10:12 sail-sail