Adding Custom style for Pivot table epplus - pivot-table

Hi i have successfully created a pivot table using EPPlus and i have requirement to change the default color style in pivot table ,how can i achieve this in epplus

You can set the TableStyle of the pivot table like this. Here Dark2 is chosen, but there's plenty to choose from.
pivotTable.TableStyle = OfficeOpenXml.Table.TableStyles.Dark2;

Related

Automatically produce aliases for all columns in SELECT statement

I'm using Microsoft Query to pull data from MS SQL Server to Excel. Many of my tables have the same column names, for example:
[task].[active]
[user].[active]
[task].[name]
[user].[name]
When I pivot in Excel, only the column names are shown. A pivot filter might have multiple fields called "active" which is very confusing.
I'd like to alias every column with the table name it's from, so that in the filter it would say "task_active" and "user_active". My Excel SELECT statement would be:
SELECT active AS task_active, name AS task_name FROM task...
Is there a quick way to prepend the table name to an alias using a formatting tool? I have Apex SQL Refactor, and Notepad++ but I haven't found a way to do this without having to manually type all of the column names again.
If you populate resultset to datatable then datatable to excel then it will automatically change duplicate column name to col1,col2 etc.
This is not your requirement.you want it to be specific.
Method 1 . Create temp table with desire column name
Insert the result in #temp table
Return #temp table result set
Method 2 : Use dynamic query.
Wht your real query look like ?

Excel column order from powerpivot

How can I rearrange column order from powerpivot data model? Unchecking/checking Preserve column sort/filter/layout doesn't work.
For example in powerPivot I have something like this:
col1 | calculatedCol | col2
But in Excel table:
col1 | col2 | calculatedCol
Drag and drop columns in diagram view also doesn't work.
You can rearrange columns order in the Data View window itself by selecting a column and then dragging to the desired location. Doesn't it work for you?
Is your issue that the Data Model and your Excel table don't match? Have you tried adding the table again, or just rearrange the columns in Excel to match your Data Model?
try to select the cell with the column header in the pivot table and horizontally drag it to its new position

To add a column to a view

I am now working on a View in SQL Server 2012 which is very long (has around 800 columns). We allow users to add custom columns to the table(A separate UI that allows user to specify column name, type and max length).Once the column is added to the table, it must be reflected in the view too. Is there a way to automatically accomplish this ? Right now, I need to create an alter view statement with the already existing 800+ columns and newly added column. Also, can sp_refreshview be used for this purpose? Looking for some answers. Thanks in advance.
If you manually set which columns are included to view (I mean SELECT column1, column2 FROM), then the automatic update probably isn't possible.
If SELECT * is used in view (bad practice), there is a solution:
exec sp_refreshview [dbo.v_customer]
And its more common form here (update all views).

drop down select list in CakePHP

I want to generate a drop down select list with the form helper of CakePHP,
I'am trying to pass an array in the $this->Form->input() method which is obtained in the folowing
way $colors = $this->Color->find('all',...);$this->set('colors', $colors);.
thanks in advance.
UPDATE:
What I'm trying to do in CakePHP is this (in SQL code):
SELECT id, color
FROM colors Color WHERE id NOT IN (SELECT color_id FROM product_size_colors psc WHERE psc.product_id=16);
How can I replicate the above query in cakephp?
find('list') is what you need to look into...
by default thats going to get the id,name fields..
$colors = $this->Color->find('list');
$this->set('colors', $colors);

how to export records/data from one database table to another database table?

How do you export records from one database table and import it into another database table?
(same table structure).
If the table have the exact same structure, and no autogenerated fields you can use:
insert into DestinationTable
select * from SourceTable
You can also use the
select *
into DestinationTable
from SourceTable
syntax, to create and fill the destination table on the fly.
If you also want to keep you identity colums same you can easily do it using code smith template. Download the templates from here and use ScriptTableData.cst template in them. Before that you will required to install code smith on you machine too.

Resources