I am working on Windows application with c#.
I have a word document.
I am removing headers & footers in word file programatically.
I am doing this with Microsoft.Office.Interop.Word.
after removing headers and footers, I found some tables got split in pages.
I want to set AllowBreakAcrossPages property to each row of every table.
How to do this in C# code?
Please help me
You need loop all the tables in this word document. note the index start with 1, not 0 if you just want one specific table to set.
For each oTable As Word.Table in appWord.ActiveDocument.Tables
oTable.AllowPageBreaks = False
oTable.Rows.AllowBreakAcrossPages = False 'This line is very important to make it work
next
Check your word document to see whether your target table is embedded in some other, make sure the loop access the target table for the property setting.
Related
I have some data that I want to be displayed the following way and I cannot find how to do it:
For example this would be the keep together case:
But I don't like that I have a lot of blank spaces when data is too much, so I would like the following to happen if possible.
When the colNames and the first row can fit in the remaining space put them there.
Or if more can fit after the first row, put all of them there and split where it is possible if necessary.
Basically I want a 'Keep together' option for the columns and first row, and everything else can be splitted at any point.
If anyone wants to achieve the same functionality do the following:
Put the table column names inside a GroupHeader and set its GroupUnion property to WithFirstDetail.
Put the table rows in the Detail next to the GroupHeader.
By doing this the WithFirstDetail property, as the name suggests, will try to keep the header with the first record, or move to the next page. Therefore achieving the behavior described above.
I'm writing a script that's intended to work for multiple layouts and table occurrences. For each, it will determine the primary key and then find the maximum value in any record for that primary key field. That's all working well. Now, I've computed my intended next serial value and would like to assign this to a field whose name I have saved in a variable. I am unable to specify the target field by using a variable. I only see an option for selecting the table and field from a list of existing fields.
My questions:
Is there a way to dynamically specify the target field?
Why is there a checkbox for "specify target field"? I see that I receive error 102 (missing field) when I do not specify a target field. I don't understand why it's optional but returns an error if it is not used. Why not make it mandatory?
I've tried:
The script step "Go to field". I was hoping that having this script step placed before "set next serial value" would allow me to leave "specify target field" blank. But there's still error 102 for "set next serial value". And "go to field" also cannot be specified dynamically.
I'm working with FileMaker 11, but I've also investigated FileMaker 15 and it's also not possible to specify a target field from a calculation. In both FM 11 and 15, it's possible to specify the number of repetitions from a calculation, but not the target.
I've considered various approaches for determining the next serial value but all of these hinge on being able to specify the target dynamically. In case this is not possible, I will need to re-think my strategy and write scripts for each table in the database separately.
Here's a discussion on the same question that I have. http://fmforums.com/topic/93934-set-dynamic-next-serial-value/ My question about why "specify target field" is optional was not answered there so I thought I would ask the question here in case anyone has additional information.
As you might notice, I'm relatively new here, so I would also appreciate any tips about how I can improve the formatting or content of this question.
Before we had Set Next Serial Value, we used Replace Field Contents to get the same effect, but it's more complicated, although it will allow you to do it dynamically. The basic idea is that you'll need to be on the record that has the maximum serial number, isolate that record, make sure you're on a layout with the serial number field, go to that field, and use Replace Field Contents to set the field to itself while also updating the next serial value. The script would look something like this:
Go to Layout [ // layout that has the target field ]
Enter Find Mode
Set Field By Name [ $_target_field ; $_max_serial ]
Perform Find
Loop
Go to Next Field
Exit Loop If [ Get(ActiveFieldTableName) & "::" & Get(ActiveFieldName) = $_target_field ]
End Loop
Replace Field Contents [ No Dialog ; Replace with serial numbers: Custom values ; Initial Value: $_max_serial ; Increment by: 1 ; Update serial number in Entry Options ]
No, I haven't tested this out on a sample file, but it's the basic technique we used before FileMaker, Inc. gave us Set Next Serial Value.
I found a great tutorial for building a nicer (dynamic) multibox, without extensions.
I was able to use it, and I really love it.
However, I have an issue:
if I use a multibox with a master detail table, then if I filter it from detail then master will automatically selected. The below example shows a normal multibox at the top, and dynamic/pivot multibox at the bottom:
How I can achieve this with my dynamic multibox?
For the label, I use:
=if(IsNull(GetFieldSelections(master)) = -1, 'Master',GetFieldSelections(master))
with this, I can set 'Master' as the label.
I can see data has seen filtered but I didn't find a function to get data that has been filtered to set it in the label, maybe someone here can give me an advice to solve this.
The GetFieldSelections() will only give you the list of explicitly selected items. By selecting items in the detail, you're only selecting from the master implicitly.
Try using Concat() instead. This will give you the list of possible values for a field that isn't being directly selected upon.
Your next big headache will be how to determine when to show 'Master' or not. One possible method is to compare the full list of possible values in Master to the possible list. In the example below, I do this by comparing the possible count of master count(master) with the full list of possible values in master count({1}master).
Combining these, one solution could be:
=if(count(master)=count({1}master),'Master',Concat(master,', '))
I am working on my first SSIS package. I have a view with data that looks something like:
Loc Data
1 asd
1 qwe
2 zxc
3 jkl
And I need all of the rows to go to different files based on the Loc value. So all of the data rows where Loc = 1 should end up in the file named Loc1.txt, and the same for each other Loc.
It seems like this can be accomplished with a conditional split to flat file, but that would require a destination for each Location. I have a lot of Locations, and they all will be handled the same way other than being split in to different files.
Is there a built in way to do this without creating a bunch of destination components? Or can I at least use the script component to act as a way?
You should be able to set an expression using a variable. Define your path up to the directory and then set the variable equal to that column.
You'll need an Execute SQL task to return a Single Row result set, and loop that in a container for every row in your original result set.
I don't have access at the moment to post screenshots, but this link should help outline the steps.
So when your package runs the expression will look like:
'C:\Documents\MyPath\location' + #User::LocationColumn + '.txt'
It should end up feeding your directory with files according to location.
Set the User::LocationColumn equal to the Location Column in your result set. Write your result set to group by Location, so all your records write to a single file per Location.
I spent some time try to complete this task using the method #Phoenix suggest, but stumbled upon this video along the way.
I ended up going with the method shown in the video. I was hoping I wouldn't have to separate it in to multiple select statements for each location and an extra one to grab the distinct locations, but I thought the SSIS implementation in the video was much cleaner than the alternative.
Change the connection manager's connection string, in which you have to use variable which should be changed.
By varying the variable, destination file also changes
and connection string is :
'C:\Documents\ABC\Files\' + #User::data + '.txt'
vote this if it helps you
I'm doing an Excel loop through fifty or more Excel files. The loop goes through each Excel file, grabs all the data and inputs it into the database without error. This is the typical process of setting delay validation to true, and making sure that the expression for the Excel Connection is a string variable called EFile that is set to nothing (in the loop).
What is not working: trying to input the name of the Excel file into the database.
What's been tried (edit; SO changed my 2 to 1 - don't know why):
Add a derived column between the Excel file and database input, and add a column using the EFile expression (so under Expression in the Derived Column it would be #[User::EFile]). and add the empty. However, this inputs nothing a blank (nothing).
One suggestion was to add ANOTHER string variable and set its properties EvaluateAsExpression to True and set the Expression to the EFile variable (#[User::EFile]). The funny thing is that this does the same thing - inputs a blank into the database.
Numerous people on blogs claim they can do this, yet I haven't seen one actually address this (I have a blog and I will definitely be showing people how to do this when I get an answer because, so far, these others have fallen short). How do I grab an Excel file's name and input it in a database during a loop?
Added: Forgot to add, no scripts; the claim is that it can be done without them, so I want to see the solution without them.
Note: I already have the ability to import the data from the Excel files - that's easy (see my GitHub account, as I have two different projects for importing all sorts of txt, csv, xls, xlsx data). I am trying to also get the actual name of the file being imported also into the database. So, if there are fifty Excel files, along with the data in each file, the database will have the fifty file names alongside that data (so if each file has 1000 rows of data, each 1000 rows would also have the name of the file they came from next to them as an additional column). This point seems to cause a lot of confusion, as people assume I'm having trouble importing data in files - NOPE, see my GitHub; again that's easy. It's the FILENAME that needs to also be imported.
Test package: https://github.com/tmmtsmith/SSISLoopWithFileName
Solution: #jaimet pointed out that the Derived Column needed to be the #[User::CurrentFile] (see the test package). When I first ran the package, I still got a blank value in my database. But when we originally set up the connection, we do point it to an actual file (I call this "fooling the package"), then change the expression on the connecting later to the #[User::CurrentFile], which is blank. The Derived Column, using the variable #[User::CurrentFile], showed a string of 0. So, I removed the Derived Column, put the full file path and name in the variable, then added the variable to the Derived Column (which made it think the string was 91 characters long), then went back and set the variable to nothing (English teacher would hate the THENs about right now). When I ran the package, it inputted the full file path. Maybe, like the connection, it needs to initially think that a file exists in order for it to input the full amount of characters?
Appreciate all the help.
The issue is because of blank value in the variable #[User::FileNameInput] and this caused the SSIS package to assume that the value of this variable will always be of zero length in the Derived Column transformation.
Change the expression on the Derived column transformation from #[User::FileNameInput] to (DT_STR, 2000, 1252)#[User::FileNameInput].
Type casting the derived column to 2000 sets the column length to that maximum value. The value 1252 represents the code page. I assumed that you are using ANSI code page. I took the value 2000 from your table definition because the FilePath column had variable VARCHAR(2000). If the column data type had been NVARCHAR(2000), then the expression would be (DT_WSTR, 2000)#[User::FileNameInput]
Tim,
You're using the wrong variable in your Derived Column component. You are storing the filename in #[User::CurrentFile] but the variable that you're using in your Derived Column component is #[User::FileNameInput]
Change your Derived Column component to use #[User::CurrentFile] and you'll be good.
Hope that helps.
JT
If you are using a ForEach loop to process the files in a folder then I have have used the technique described in SSIS Junkie's blog to get the filename in to an SSIS variable: SSIS: Enumerating files in a Foreach loop
You can use the variable later in your flow to write it to the database.
TO all intents and purposes your method #1 should work. That's exactly how I would attempt to do it. I am baffled as to why it is not working. Could you perhaps share your package?
Tony, thanks very much for the link. Much appreciated.
Regards
Jamie